From 9640c43cb8a732124650c3a11121cb0ff8de2e90 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Fri, 19 Apr 2024 11:16:02 -0500 Subject: [PATCH 1/6] fix circular dependency by moving registered subclasses to a module --- server/app/admin/reports_admin.rb | 6 +++--- server/app/reports/report.rb | 3 --- server/app/reports/reports.rb | 5 +++++ 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 server/app/reports/reports.rb diff --git a/server/app/admin/reports_admin.rb b/server/app/admin/reports_admin.rb index d02ab0a60..717cccf45 100644 --- a/server/app/admin/reports_admin.rb +++ b/server/app/admin/reports_admin.rb @@ -5,15 +5,15 @@ controller do def index - @reports = Report::AVAILABLE_REPORTS + @reports = Reports::AVAILABLE_REPORTS end def show - @report = Report::AVAILABLE_REPORTS.find { |x| params[:name] == x.name } + @report = Reports::AVAILABLE_REPORTS.find { |x| params[:name] == x.name } end def generate_report - @report = Report::AVAILABLE_REPORTS.find { |x| params[:name] == x.name } + @report = Reports::AVAILABLE_REPORTS.find { |x| params[:name] == x.name } report_params = params.permit(@report.inputs.keys).to_h.symbolize_keys #checkbox will come in as 0 or 1 #cast it to a boolean here so reports dont have to worry about that diff --git a/server/app/reports/report.rb b/server/app/reports/report.rb index 9905a8073..611599a42 100644 --- a/server/app/reports/report.rb +++ b/server/app/reports/report.rb @@ -1,7 +1,4 @@ class Report - AVAILABLE_REPORTS = [ - OrganizationContributions - ] def initialize(params) setup(**params) diff --git a/server/app/reports/reports.rb b/server/app/reports/reports.rb new file mode 100644 index 000000000..18c2fa868 --- /dev/null +++ b/server/app/reports/reports.rb @@ -0,0 +1,5 @@ +module Reports + AVAILABLE_REPORTS = [ + OrganizationContributions + ] +end From 03006e1a6a8d70f5dc010ae18cc8946d14a89a7b Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Fri, 19 Apr 2024 11:19:51 -0500 Subject: [PATCH 2/6] group utils and reports in menu section --- server/app/admin/reports_admin.rb | 4 +++- server/app/admin/utilities_admin.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/app/admin/reports_admin.rb b/server/app/admin/reports_admin.rb index 717cccf45..0d411ec44 100644 --- a/server/app/admin/reports_admin.rb +++ b/server/app/admin/reports_admin.rb @@ -1,6 +1,8 @@ Trestle.admin(:reports) do menu do - item :reports, icon: "fas fa-file-alt" + group :tools do + item :reports, icon: "fas fa-file-alt" + end end controller do diff --git a/server/app/admin/utilities_admin.rb b/server/app/admin/utilities_admin.rb index c099b77a5..15dc4e864 100644 --- a/server/app/admin/utilities_admin.rb +++ b/server/app/admin/utilities_admin.rb @@ -1,6 +1,8 @@ Trestle.admin(:utilities) do menu do - item :utilities, icon: "fas fa-cogs" + group :tools do + item :utilities, icon: "fas fa-cogs" + end end controller do From 17ad7058fdf4f86bed2dea9ac055d17151d59e09 Mon Sep 17 00:00:00 2001 From: Susanna Kiwala Date: Fri, 19 Apr 2024 14:42:11 -0500 Subject: [PATCH 3/6] 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 From cf5da0c955b3d052bd6c9635c981295dfbc7b30e Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Fri, 19 Apr 2024 14:43:14 -0500 Subject: [PATCH 4/6] add link adaptors for variant subtypes --- server/app/lib/link_adaptors/factor_variant.rb | 4 ++++ server/app/lib/link_adaptors/gene_variant.rb | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 server/app/lib/link_adaptors/factor_variant.rb create mode 100644 server/app/lib/link_adaptors/gene_variant.rb diff --git a/server/app/lib/link_adaptors/factor_variant.rb b/server/app/lib/link_adaptors/factor_variant.rb new file mode 100644 index 000000000..5cf2c1da5 --- /dev/null +++ b/server/app/lib/link_adaptors/factor_variant.rb @@ -0,0 +1,4 @@ +module LinkAdaptors + class FactorVariant < Variant + end +end diff --git a/server/app/lib/link_adaptors/gene_variant.rb b/server/app/lib/link_adaptors/gene_variant.rb new file mode 100644 index 000000000..2e11df824 --- /dev/null +++ b/server/app/lib/link_adaptors/gene_variant.rb @@ -0,0 +1,4 @@ +module LinkAdaptors + class GeneVariant < Variant + end +end From fbe566216fd1d4d375cd2fe9b5ff13c18d680fa9 Mon Sep 17 00:00:00 2001 From: Susanna Kiwala Date: Fri, 19 Apr 2024 14:57:04 -0500 Subject: [PATCH 5/6] Fix SetAlleleRegistryIdSingleVariant job --- server/app/jobs/set_allele_registry_id_single_variant.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app/jobs/set_allele_registry_id_single_variant.rb b/server/app/jobs/set_allele_registry_id_single_variant.rb index 49149d312..8fe42f7a0 100644 --- a/server/app/jobs/set_allele_registry_id_single_variant.rb +++ b/server/app/jobs/set_allele_registry_id_single_variant.rb @@ -21,6 +21,6 @@ def perform(variant) delete_allele_registry_link(old_allele_registry_id) end end - GenerateOpenCravatLink.perform_later(self) + GenerateOpenCravatLink.perform_later(variant) end end From ce91bf78c0d5bd90c1e165aed3bd202c5e162205 Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Fri, 19 Apr 2024 15:06:25 -0500 Subject: [PATCH 6/6] always use the base class in search, not the inherited type --- server/app/graphql/resolvers/quicksearch.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app/graphql/resolvers/quicksearch.rb b/server/app/graphql/resolvers/quicksearch.rb index b26dd402f..63f5d5f3d 100644 --- a/server/app/graphql/resolvers/quicksearch.rb +++ b/server/app/graphql/resolvers/quicksearch.rb @@ -40,7 +40,7 @@ def resolve(query:, types: nil, highlight_matches: false) { id: res.id, name: format_name(res.name, highlights), - result_type: res.class, + result_type: res.class.base_class, matching_text: format_highlights(highlights) } end