Permalink
Browse files

Only track ODbL cleanness once for each version - don't recompute fro…

…m scratch each time.
  • Loading branch information...
1 parent 2c9ac3b commit d204cf9a76443e25fe20fcf4d88926a77318e445 @zerebubuth committed Apr 26, 2012
Showing with 10 additions and 5 deletions.
  1. +10 −5 change_bot.rb
View
15 change_bot.rb
@@ -14,12 +14,17 @@ def initialize(versions, db)
@versions.sort_by! {|obj| obj.version}
end
- def odbl_clean? (o)
+ def odbl_clean_versions
# we need to track odbl clean-ness. if the tag is set and
# later unset, then we consider it a mistake.
- # see if o and all later objects have the odbl=clean tag
- @versions.drop_while {|obj| o != obj}.all? {|obj| Tags.odbl_clean?(obj.tags)}
+ # first, figure out which versions are clean.
+ version_is_clean = @versions.map {|obj| Tags.odbl_clean?(obj.tags)}
+
+ # iterate backwards, propagating uncleanness where the
+ # flag is reset.
+ global = true
+ version_is_clean.reverse.map {|flag| global = flag && global}.reverse
end
def actions
@@ -30,7 +35,7 @@ def actions
tainted_tags = Array.new
- @versions.each do |obj|
+ @versions.zip(odbl_clean_versions).each do |obj,is_odbl_clean|
# deletions are always "clean", and we consider them to
# have no tags and the "version zero" geometry. what
# happens after that may be a revert to a previous version.
@@ -47,7 +52,7 @@ def actions
# is this version clean? there are many ways to be
# clean, and we try to enumerate them here.
- status = if odbl_clean?(obj)
+ status = if is_odbl_clean
:odbl_clean
elsif changeset_is_accepted?(obj.changeset_id)
:acceptor_edit

0 comments on commit d204cf9

Please sign in to comment.