Skip to content

Commit

Permalink
Fixing conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
caiosba committed Feb 20, 2025
2 parents d710b60 + ae4b6b4 commit 8ceee25
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/graph/types/team_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ def statistics(period:, language: nil, platform: nil)
TeamStatistics.new(object, period, language, platform)
end

field :statistics_platforms, [GraphQL::Types::String], null: true, description: 'List of tipline platforms for which we have data.'

field :bot_query, [TiplineSearchResultType], null: true do
argument :search_text, GraphQL::Types::String, required: true
argument :threshold, GraphQL::Types::Float, required: false
Expand Down
5 changes: 5 additions & 0 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ def get_dashboard_exported_data(filters, dashboard_type)
data
end

# Platforms for which statistics are available (e.g., at least one media request)
def statistics_platforms
TiplineRequest.joins(:project_media).where('project_medias.team_id' => self.id).group('platform').count.keys
end

# private
#
# Please add private methods to app/models/concerns/team_private.rb
Expand Down
5 changes: 5 additions & 0 deletions lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13418,6 +13418,11 @@ type Team implements Node {
sources_count(keyword: String): Int
spam_count: Int
statistics(language: String, period: String!, platform: String): TeamStatistics

"""
List of tipline platforms for which we have data.
"""
statistics_platforms: [String!]
tag_texts(
"""
Returns the elements in the list that come after the specified cursor.
Expand Down
22 changes: 22 additions & 0 deletions public/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -71014,6 +71014,28 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "statistics_platforms",
"description": "List of tipline platforms for which we have data.",
"args": [

],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "tag_texts",
"description": null,
Expand Down
10 changes: 10 additions & 0 deletions test/models/team_2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1649,4 +1649,14 @@ def setup
t.filtered_articles
end
end

test "should return platforms for which statistics are available" do
t = create_team
pm = create_project_media team: t
assert_equal [], t.statistics_platforms
create_tipline_request team_id: t.id, platform: 'telegram', associated: pm
create_tipline_request team_id: t.id, platform: 'whatsapp', associated: pm
create_tipline_request team_id: t.id, platform: 'whatsapp', associated: pm
assert_equal ['telegram', 'whatsapp'], t.reload.statistics_platforms.sort
end
end

0 comments on commit 8ceee25

Please sign in to comment.