analytics: Add backend for messages read over time graph.

This commit includes changes in the api /json/analytics/chart_data to
send data for the newly added graph, as well as tests.
This commit is contained in:
arpit551
2020-06-11 16:26:06 +05:30
committed by Tim Abbott
parent a4b857b635
commit aa70baba71
2 changed files with 23 additions and 0 deletions

View File

@@ -236,6 +236,12 @@ def get_chart_data(request: HttpRequest, user_profile: UserProfile, chart_name:
{str(id): name for id, name in Client.objects.values_list('id', 'name')}}
labels_sort_function = sort_client_labels
include_empty_subgroups = False
elif chart_name == 'messages_read_over_time':
stats = [COUNT_STATS['messages_read::hour']]
tables = [aggregate_table, UserCount]
subgroup_to_label = {stats[0]: {None: 'read'}}
labels_sort_function = None
include_empty_subgroups = True
else:
raise JsonableError(_("Unknown chart name: %s") % (chart_name,))