Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding two new data points for the data dashboards. #2225

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/graph/types/team_statistics_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions lib/team_statistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 28 additions & 0 deletions public/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions test/lib/team_statistics_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading