From 121df39f15174a8c1421fbec30421fb41ea8a4ad Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Fri, 9 Aug 2024 10:22:54 -0500 Subject: [PATCH] remove rejected EIDs and Assertions from MP relations by default --- client/src/app/generated/server.model.graphql | 2 ++ client/src/app/generated/server.schema.json | 24 ++++++++++++++ .../types/entities/molecular_profile_type.rb | 31 ++++++++++++++----- server/app/models/molecular_profile.rb | 8 +++++ 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/client/src/app/generated/server.model.graphql b/client/src/app/generated/server.model.graphql index 7efeff579..8ba2abfd1 100644 --- a/client/src/app/generated/server.model.graphql +++ b/client/src/app/generated/server.model.graphql @@ -5682,6 +5682,7 @@ type MolecularProfile implements Commentable & EventOriginObject & EventSubject Returns the first _n_ elements from the list. """ first: Int + includeRejected: Boolean """ Returns the last _n_ elements from the list. @@ -5798,6 +5799,7 @@ type MolecularProfile implements Commentable & EventOriginObject & EventSubject Returns the first _n_ elements from the list. """ first: Int + includeRejected: Boolean """ Returns the last _n_ elements from the list. diff --git a/client/src/app/generated/server.schema.json b/client/src/app/generated/server.schema.json index 63c2d0a79..f37995794 100644 --- a/client/src/app/generated/server.schema.json +++ b/client/src/app/generated/server.schema.json @@ -27074,6 +27074,18 @@ "defaultValue": null, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "includeRejected", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null } ], "type": { @@ -27497,6 +27509,18 @@ "defaultValue": null, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "includeRejected", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null } ], "type": { diff --git a/server/app/graphql/types/entities/molecular_profile_type.rb b/server/app/graphql/types/entities/molecular_profile_type.rb index e702713b1..8203a827a 100644 --- a/server/app/graphql/types/entities/molecular_profile_type.rb +++ b/server/app/graphql/types/entities/molecular_profile_type.rb @@ -15,10 +15,17 @@ class MolecularProfileType < Types::BaseObject description: 'The profile name with its constituent parts as objects, suitable for building tags.' field :variants, [Types::Interfaces::VariantInterface], null: false, description: 'The collection of variants included in this molecular profile. Please note the name for their relation to each other.' - field :assertions, Types::Entities::AssertionType.connection_type, null: false, - description: 'The collection of assertions associated with this molecular profile.' - field :evidence_items, Types::Entities::EvidenceItemType.connection_type, null: false, - description: 'The collection of evidence items associated with this molecular profile.' + + field :assertions, Types::Entities::AssertionType.connection_type, null: false do + description 'The collection of assertions associated with this molecular profile.' + argument :include_rejected, Boolean, required: false + end + + field :evidence_items, Types::Entities::EvidenceItemType.connection_type, null: false do + description 'The collection of evidence items associated with this molecular profile.' + argument :include_rejected, Boolean, required: false + end + field :sources, [Types::Entities::SourceType], null: false field :description, String, null: true field :molecular_profile_aliases, [String], null: false @@ -77,12 +84,20 @@ def complex_molecular_profile_creation_activity Loaders::AssociationLoader.for(MolecularProfile, :complex_molecular_profile_creation_activity).load(object) end - def assertions - Loaders::AssociationLoader.for(MolecularProfile, :assertions).load(object) + def assertions(include_rejected: false) + if include_rejected + Loaders::AssociationLoader.for(MolecularProfile, :assertions).load(object) + else + Loaders::AssociationLoader.for(MolecularProfile, :submitted_and_accepted_assertions).load(object) + end end - def evidence_items - Loaders::AssociationLoader.for(MolecularProfile, :evidence_items).load(object) + def evidence_items(include_rejected: false) + if include_rejected + Loaders::AssociationLoader.for(MolecularProfile, :evidence_items).load(object) + else + Loaders::AssociationLoader.for(MolecularProfile, :submitted_and_accepted_evidence_items).load(object) + end end def sources diff --git a/server/app/models/molecular_profile.rb b/server/app/models/molecular_profile.rb index 53328abc0..cba4f54e0 100644 --- a/server/app/models/molecular_profile.rb +++ b/server/app/models/molecular_profile.rb @@ -9,7 +9,15 @@ class MolecularProfile < ActiveRecord::Base has_and_belongs_to_many :variants has_and_belongs_to_many :sources has_many :assertions + has_many :submitted_and_accepted_assertions, + ->() { where.not(status: 'rejected') }, + class_name: 'Assertion' + has_many :evidence_items + has_many :submitted_and_accepted_evidence_items, + ->() { where.not(status: 'rejected') }, + class_name: 'EvidenceItem' + has_one :evidence_items_by_status has_one :evidence_items_by_type has_and_belongs_to_many :molecular_profile_aliases, join_table: :molecular_profile_aliases_molecular_profiles