mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
Fix aggregation to analytics summary tables.
There are a number of different stats that need to be propagated from UserCount and StreamCount to RealmCount, and from RealmCount to InstallationCount. Stats with hour intervals also need to have their day values propagated. This commit fixes a bug in the summary table aggregation logic so that for a given interval on a CountStat object we pull the correct counts for the interval as well as do the day aggregation if required. We Also ensure that any aggregation then done from the realmcount table to the installationcount table follows the same aggregation logic for intervals.
This commit is contained in:
@@ -3,7 +3,7 @@ from datetime import timedelta, datetime
|
||||
|
||||
from analytics.models import InstallationCount, RealmCount, \
|
||||
UserCount, StreamCount, HuddleCount, BaseCount
|
||||
from analytics.lib.interval import TimeInterval, timeinterval_range
|
||||
from analytics.lib.interval import TimeInterval, timeinterval_range, subintervals
|
||||
from zerver.models import Realm, UserProfile, Message, Stream, models
|
||||
|
||||
from typing import Any, Optional, Type
|
||||
@@ -39,11 +39,10 @@ def process_count_stat(stat, range_start, range_end):
|
||||
|
||||
# aggregate to summary tables
|
||||
for interval in ['hour', 'day', 'gauge']:
|
||||
for frequency in ['hour', 'day']:
|
||||
for time_interval in timeinterval_range(range_start, range_end, interval, frequency):
|
||||
analytics_table = stat.zerver_count_query.analytics_table
|
||||
if stat.smallest_interval <= interval and stat.frequency == frequency and \
|
||||
analytics_table in (UserCount, StreamCount):
|
||||
for time_interval in timeinterval_range(range_start, range_end, interval, stat.frequency):
|
||||
analytics_table = stat.zerver_count_query.analytics_table
|
||||
if stat.smallest_interval in subintervals(interval):
|
||||
if analytics_table in (UserCount, StreamCount):
|
||||
do_aggregate_to_summary_table(stat, time_interval, analytics_table, RealmCount)
|
||||
do_aggregate_to_summary_table(stat, time_interval, RealmCount, InstallationCount)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user