Skip to content

Commit

Permalink
remove rejected EIDs and Assertions from MP relations by default
Browse files Browse the repository at this point in the history
  • Loading branch information
acoffman committed Aug 13, 2024
1 parent f637997 commit 121df39
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 8 deletions.
2 changes: 2 additions & 0 deletions client/src/app/generated/server.model.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions client/src/app/generated/server.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
31 changes: 23 additions & 8 deletions server/app/graphql/types/entities/molecular_profile_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions server/app/models/molecular_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 121df39

Please sign in to comment.