mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 11:52:01 +00:00
counts.py: Hardcode is_active=true in count_user_by_realm_query.
A step towards removing filter_args from the CountStat object.
This commit is contained in:
@@ -250,6 +250,8 @@ def do_increment_logging_stat(zerver_object, stat, subgroup, event_time, increme
|
|||||||
row.value = F('value') + increment
|
row.value = F('value') + increment
|
||||||
row.save(update_fields=['value'])
|
row.save(update_fields=['value'])
|
||||||
|
|
||||||
|
# Hardcodes the query needed by active_users:is_bot:day, since that is
|
||||||
|
# currently the only stat that uses this.
|
||||||
count_user_by_realm_query = """
|
count_user_by_realm_query = """
|
||||||
INSERT INTO analytics_realmcount
|
INSERT INTO analytics_realmcount
|
||||||
(realm_id, value, property, subgroup, end_time)
|
(realm_id, value, property, subgroup, end_time)
|
||||||
@@ -262,8 +264,8 @@ count_user_by_realm_query = """
|
|||||||
WHERE
|
WHERE
|
||||||
zerver_realm.date_created < %%(time_end)s AND
|
zerver_realm.date_created < %%(time_end)s AND
|
||||||
zerver_userprofile.date_joined >= %%(time_start)s AND
|
zerver_userprofile.date_joined >= %%(time_start)s AND
|
||||||
zerver_userprofile.date_joined < %%(time_end)s
|
zerver_userprofile.date_joined < %%(time_end)s AND
|
||||||
%(join_args)s
|
zerver_userprofile.is_active = TRUE
|
||||||
GROUP BY zerver_realm.id %(group_by_clause)s
|
GROUP BY zerver_realm.id %(group_by_clause)s
|
||||||
"""
|
"""
|
||||||
zerver_count_user_by_realm = ZerverCountQuery(UserProfile, RealmCount, count_user_by_realm_query)
|
zerver_count_user_by_realm = ZerverCountQuery(UserProfile, RealmCount, count_user_by_realm_query)
|
||||||
@@ -460,7 +462,7 @@ count_stats_ = [
|
|||||||
# Sanity check on the bottom two stats. Is only an approximation,
|
# Sanity check on the bottom two stats. Is only an approximation,
|
||||||
# e.g. if a user is deactivated between the end of the day and when this
|
# e.g. if a user is deactivated between the end of the day and when this
|
||||||
# stat is run, they won't be counted.
|
# stat is run, they won't be counted.
|
||||||
CountStat('active_users:is_bot:day', zerver_count_user_by_realm, {'is_active': True},
|
CountStat('active_users:is_bot:day', zerver_count_user_by_realm, {},
|
||||||
(UserProfile, 'is_bot'), CountStat.DAY, interval=TIMEDELTA_MAX),
|
(UserProfile, 'is_bot'), CountStat.DAY, interval=TIMEDELTA_MAX),
|
||||||
# In RealmCount, 'active_humans_audit::day' should be the partial sum sequence
|
# In RealmCount, 'active_humans_audit::day' should be the partial sum sequence
|
||||||
# of 'active_users_log:is_bot:day', for any realm that started after the
|
# of 'active_users_log:is_bot:day', for any realm that started after the
|
||||||
|
|||||||
Reference in New Issue
Block a user