implications: count 'queued' implications as active.

Bug: implications that were approved but that were still in the 'queued'
state were not seen as active yet, which led to the transitivity
validation passing because it didn't include queued implications.
This commit is contained in:
evazion
2017-07-04 20:33:45 -05:00
parent 542c673221
commit aac1463fbf

View File

@@ -32,7 +32,7 @@ class TagImplication < ApplicationRecord
module ClassMethods
# assumes names are normalized
def with_descendants(names)
(names + where("antecedent_name in (?) and status in (?)", names, ["active", "processing"]).map(&:descendant_names_array)).flatten.uniq
(names + active.where(antecedent_name: names).flat_map(&:descendant_names_array)).uniq
end
def automatic_tags_for(names)
@@ -49,7 +49,7 @@ class TagImplication < ApplicationRecord
until children.empty?
all.concat(children)
children = TagImplication.where("antecedent_name IN (?) and status in (?)", children, ["active", "processing"]).map(&:consequent_name)
children = TagImplication.active.where(antecedent_name: children).pluck(:consequent_name)
end
end.sort.uniq
end
@@ -97,7 +97,7 @@ class TagImplication < ApplicationRecord
end
def active
where("status IN (?)", ["active", "processing"])
where(status: %w[active processing queued])
end
def search(params)