Skip to content

Commit

Permalink
Return team for fact check mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Jul 19, 2024
1 parent 8a201eb commit 33e04d7
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/graph/mutations/fact_check_mutations.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module FactCheckMutations
MUTATION_TARGET = 'fact_check'.freeze
PARENTS = ['claim_description'].freeze
PARENTS = ['claim_description', 'team'].freeze

module SharedCreateAndUpdateFields
extend ActiveSupport::Concern
Expand Down
4 changes: 4 additions & 0 deletions app/models/concerns/team_associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,8 @@ def check_search_unconfirmed
def check_search_spam
check_search_filter({ 'archived' => CheckArchivedFlags::FlagCodes::SPAM })
end

def fact_checks
FactCheck.joins(:claim_description).where('claim_descriptions.team_id' => self.id)
end
end
4 changes: 4 additions & 0 deletions app/models/fact_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def team_id
self.claim_description&.team_id
end

def team
self.claim_description&.team
end

private

def set_language
Expand Down
3 changes: 3 additions & 0 deletions lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,7 @@ type CreateFactCheckPayload {
clientMutationId: String
fact_check: FactCheck
fact_checkEdge: FactCheckEdge
team: Team
}

"""
Expand Down Expand Up @@ -4212,6 +4213,7 @@ type DestroyFactCheckPayload {
"""
clientMutationId: String
deletedId: ID
team: Team
}

"""
Expand Down Expand Up @@ -15569,6 +15571,7 @@ type UpdateFactCheckPayload {
clientMutationId: String
fact_check: FactCheck
fact_checkEdge: FactCheckEdge
team: Team
}

"""
Expand Down
42 changes: 42 additions & 0 deletions public/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -15674,6 +15674,20 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "team",
"description": null,
"args": [

],
"type": {
"kind": "OBJECT",
"name": "Team",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
Expand Down Expand Up @@ -23939,6 +23953,20 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "team",
"description": null,
"args": [

],
"type": {
"kind": "OBJECT",
"name": "Team",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
Expand Down Expand Up @@ -85316,6 +85344,20 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "team",
"description": null,
"args": [

],
"type": {
"kind": "OBJECT",
"name": "Team",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
Expand Down
5 changes: 5 additions & 0 deletions test/models/fact_check_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,9 @@ def setup
fc.save!
assert_equal 'in_progress', pm.reload.last_status
end

test "should have team" do
fc = create_fact_check
assert_not_nil fc.team
end
end

0 comments on commit 33e04d7

Please sign in to comment.