From 17ad7058fdf4f86bed2dea9ac055d17151d59e09 Mon Sep 17 00:00:00 2001 From: Susanna Kiwala Date: Fri, 19 Apr 2024 14:42:11 -0500 Subject: [PATCH] Background jobs that flag entities should use the activity, not the action --- server/app/jobs/flag_duplicate_allele_registry_ids.rb | 6 +++--- server/app/lib/importer/disease_ontology_mirror.rb | 6 +++--- server/app/lib/scrapers/human_phenotype_ontology.rb | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/app/jobs/flag_duplicate_allele_registry_ids.rb b/server/app/jobs/flag_duplicate_allele_registry_ids.rb index 6bb7ee5e1..0d5e20c33 100644 --- a/server/app/jobs/flag_duplicate_allele_registry_ids.rb +++ b/server/app/jobs/flag_duplicate_allele_registry_ids.rb @@ -10,12 +10,12 @@ def perform duplicates.each do |caid, ids| variants = Variant.where(id: ids) variants.each do |variant| - if variant.flags.select{|f| f.state == 'open' && f.comments.select{|c| c.text =~ /This Variant may be a duplicate and may need to be deprecated/ && c.user_id == 385}.count > 0}.count == 0 - Actions::FlagEntity.new( + if variant.flags.select{|f| f.state == 'open' && f.open_activity.note =~ /This Variant may be a duplicate and may need to be deprecated/ && f.open_activity.user_id == 385}.count == 0 + Activity::FlagEntity.new( flagging_user: civicbot_user, flaggable: variant, organization_id: nil, - comment: "The Allele Registry ID of this Variant is used more than once. This Variant may be a duplicate and may need to be deprecated. The following Variants all resolved to Allele Registry ID \"#{caid}\": #{ids.join(', ')}" + note: "The Allele Registry ID of this Variant is used more than once. This Variant may be a duplicate and may need to be deprecated. The following Variants all resolved to Allele Registry ID \"#{caid}\": #{ids.join(', ')}" ).perform end end diff --git a/server/app/lib/importer/disease_ontology_mirror.rb b/server/app/lib/importer/disease_ontology_mirror.rb index f0f6ee790..ff85c3b57 100644 --- a/server/app/lib/importer/disease_ontology_mirror.rb +++ b/server/app/lib/importer/disease_ontology_mirror.rb @@ -142,12 +142,12 @@ def url_from_doid(doid) def add_flags(disease, text) civicbot_user = User.find(385) (disease.evidence_items + disease.assertions).each do |obj| - if obj.flags.select{|f| f.state == 'open' && f.comments.select{|c| c.comment == text && c.user_id == 385}.count > 0}.count == 0 - Actions::FlagEntity.new( + if obj.flags.select{|f| f.state == 'open' && f.open_activity.note == text && c.open_activity.user_id == 385}.count == 0 + Activity::FlagEntity.new( flagging_user: civicbot_user, flaggable: obj, organization_id: nil, - comment: text + note: text ).perform end end diff --git a/server/app/lib/scrapers/human_phenotype_ontology.rb b/server/app/lib/scrapers/human_phenotype_ontology.rb index b68b5ee60..c703ce834 100644 --- a/server/app/lib/scrapers/human_phenotype_ontology.rb +++ b/server/app/lib/scrapers/human_phenotype_ontology.rb @@ -43,12 +43,12 @@ def self.update else civicbot_user = User.find(385) (p.evidence_items + p.assertions).each do |obj| - if obj.flags.select{|f| f.state == 'open' && f.comments.select{|c| c.text =~ /deprecated HPO term/ && c.user_id == 385}.count > 0}.count == 0 - Actions::FlagEntity.new( + if obj.flags.select{|f| f.state == 'open' && f.open_activity.note =~ /deprecated HPO term/ && f.open_activity.user_id == 385}.count == 0 + Activity::FlagEntity.new( flagging_user: civicbot_user, flaggable: obj, organization_id: nil, - comment: "This entity uses a deprecated HPO term \"#{name}\" (#{hpo_id})" + note: "This entity uses a deprecated HPO term \"#{name}\" (#{hpo_id})" ).perform end end