mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
analytics: Factor out UserCount / StreamCount common checks.
This commit is contained in:
committed by
Tim Abbott
parent
626768f626
commit
efa9bf36eb
@@ -111,6 +111,9 @@ class DataCollector:
|
|||||||
self.output_table = output_table
|
self.output_table = output_table
|
||||||
self.pull_function = pull_function
|
self.pull_function = pull_function
|
||||||
|
|
||||||
|
def depends_on_realm(self) -> bool:
|
||||||
|
return self.output_table in (UserCount, StreamCount)
|
||||||
|
|
||||||
|
|
||||||
## CountStat-level operations ##
|
## CountStat-level operations ##
|
||||||
|
|
||||||
@@ -199,7 +202,7 @@ def do_fill_count_stat_at_hour(
|
|||||||
def do_delete_counts_at_hour(stat: CountStat, end_time: datetime) -> None:
|
def do_delete_counts_at_hour(stat: CountStat, end_time: datetime) -> None:
|
||||||
if isinstance(stat, LoggingCountStat):
|
if isinstance(stat, LoggingCountStat):
|
||||||
InstallationCount.objects.filter(property=stat.property, end_time=end_time).delete()
|
InstallationCount.objects.filter(property=stat.property, end_time=end_time).delete()
|
||||||
if stat.data_collector.output_table in [UserCount, StreamCount]:
|
if stat.data_collector.depends_on_realm():
|
||||||
RealmCount.objects.filter(property=stat.property, end_time=end_time).delete()
|
RealmCount.objects.filter(property=stat.property, end_time=end_time).delete()
|
||||||
else:
|
else:
|
||||||
UserCount.objects.filter(property=stat.property, end_time=end_time).delete()
|
UserCount.objects.filter(property=stat.property, end_time=end_time).delete()
|
||||||
@@ -220,7 +223,7 @@ def do_aggregate_to_summary_table(
|
|||||||
else:
|
else:
|
||||||
realm_clause = SQL("")
|
realm_clause = SQL("")
|
||||||
|
|
||||||
if output_table in (UserCount, StreamCount):
|
if stat.data_collector.depends_on_realm():
|
||||||
realmcount_query = SQL(
|
realmcount_query = SQL(
|
||||||
"""
|
"""
|
||||||
INSERT INTO analytics_realmcount
|
INSERT INTO analytics_realmcount
|
||||||
|
|||||||
Reference in New Issue
Block a user