From c49fd6ad05cdcc2be8e99a385952d4d192721be2 Mon Sep 17 00:00:00 2001 From: Caio <117518+caiosba@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:48:03 -0300 Subject: [PATCH] Adding two new data points for the data dashboards. The two new data points are for "number of incoming messages by day" and "number of outgoing messages by day". Reference: CV2-5849. --- app/graph/types/team_statistics_type.rb | 2 ++ lib/relay.idl | 2 ++ lib/team_statistics.rb | 10 +++++++++ public/relay.json | 28 +++++++++++++++++++++++++ test/lib/team_statistics_test.rb | 4 ++++ 5 files changed, 46 insertions(+) diff --git a/app/graph/types/team_statistics_type.rb b/app/graph/types/team_statistics_type.rb index 61ddeb9f3..206e43f32 100644 --- a/app/graph/types/team_statistics_type.rb +++ b/app/graph/types/team_statistics_type.rb @@ -21,6 +21,8 @@ class TeamStatisticsType < DefaultObject field :number_of_outgoing_messages, GraphQL::Types::Int, null: true field :number_of_conversations, GraphQL::Types::Int, null: true field :number_of_messages_by_date, JsonStringType, null: true + field :number_of_incoming_messages_by_date, JsonStringType, null: true + field :number_of_outgoing_messages_by_date, JsonStringType, null: true field :number_of_conversations_by_date, JsonStringType, null: true field :number_of_search_results_by_feedback_type, JsonStringType, null: true field :average_response_time, GraphQL::Types::Int, null: true diff --git a/lib/relay.idl b/lib/relay.idl index f39ac9b59..8317c62fb 100644 --- a/lib/relay.idl +++ b/lib/relay.idl @@ -13749,6 +13749,7 @@ type TeamStatistics implements Node { number_of_fact_checks_by_rating: JsonStringType number_of_fact_checks_created: Int number_of_incoming_messages: Int + number_of_incoming_messages_by_date: JsonStringType number_of_matched_results_by_article_type: JsonStringType number_of_media_received_by_media_type: JsonStringType number_of_messages: Int @@ -13757,6 +13758,7 @@ type TeamStatistics implements Node { number_of_newsletters_delivered: Int number_of_newsletters_sent: Int number_of_outgoing_messages: Int + number_of_outgoing_messages_by_date: JsonStringType number_of_published_fact_checks: Int number_of_returning_users: Int number_of_search_results_by_feedback_type: JsonStringType diff --git a/lib/team_statistics.rb b/lib/team_statistics.rb index deed37dcb..1038ec75c 100644 --- a/lib/team_statistics.rb +++ b/lib/team_statistics.rb @@ -125,6 +125,16 @@ def number_of_messages_by_date number_of_tipline_data_points_by_date(data) end + def number_of_incoming_messages_by_date + data = CheckDataPoints.tipline_messages(@team.id, @start_date_str, @end_date_str, 'day', @platform_name, @language, 'incoming') + number_of_tipline_data_points_by_date(data) + end + + def number_of_outgoing_messages_by_date + data = CheckDataPoints.tipline_messages(@team.id, @start_date_str, @end_date_str, 'day', @platform_name, @language, 'outgoing') + number_of_tipline_data_points_by_date(data) + end + def number_of_conversations_by_date data = CheckDataPoints.tipline_requests(@team.id, @start_date_str, @end_date_str, 'day', @platform, @language) number_of_tipline_data_points_by_date(data) diff --git a/public/relay.json b/public/relay.json index bc8a5f728..19cc681da 100644 --- a/public/relay.json +++ b/public/relay.json @@ -72552,6 +72552,20 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "number_of_incoming_messages_by_date", + "description": null, + "args": [ + + ], + "type": { + "kind": "SCALAR", + "name": "JsonStringType", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "number_of_matched_results_by_article_type", "description": null, @@ -72664,6 +72678,20 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "number_of_outgoing_messages_by_date", + "description": null, + "args": [ + + ], + "type": { + "kind": "SCALAR", + "name": "JsonStringType", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "number_of_published_fact_checks", "description": null, diff --git a/test/lib/team_statistics_test.rb b/test/lib/team_statistics_test.rb index eb52414c0..2770cdb46 100644 --- a/test/lib/team_statistics_test.rb +++ b/test/lib/team_statistics_test.rb @@ -142,6 +142,10 @@ def teardown assert_equal 3, object.number_of_incoming_messages assert_equal({ '2024-01-01' => 2, '2024-01-02' => 0, '2024-01-03' => 3, '2024-01-04' => 0, '2024-01-05' => 0, '2024-01-06' => 0, '2024-01-07' => 0, '2024-01-08' => 0 }, object.number_of_messages_by_date) + assert_equal({ '2024-01-01' => 1, '2024-01-02' => 0, '2024-01-03' => 1, '2024-01-04' => 0, '2024-01-05' => 0, '2024-01-06' => 0, '2024-01-07' => 0, '2024-01-08' => 0 }, + object.number_of_outgoing_messages_by_date) + assert_equal({ '2024-01-01' => 1, '2024-01-02' => 0, '2024-01-03' => 2, '2024-01-04' => 0, '2024-01-05' => 0, '2024-01-06' => 0, '2024-01-07' => 0, '2024-01-08' => 0 }, + object.number_of_incoming_messages_by_date) assert_equal 3, object.number_of_conversations assert_equal({ '2024-01-01' => 1, '2024-01-02' => 0, '2024-01-03' => 2, '2024-01-04' => 0, '2024-01-05' => 0, '2024-01-06' => 0, '2024-01-07' => 0, '2024-01-08' => 0 }, object.number_of_conversations_by_date)