From aac1463fbf38f9d5cfd9ce74c635d231a34ec79e Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 4 Jul 2017 20:33:45 -0500 Subject: [PATCH] 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. --- app/models/tag_implication.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index 9d3882959..2e886b132 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -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)