Skip to content

Commit

Permalink
filter out standby servers
Browse files Browse the repository at this point in the history
  • Loading branch information
neilisfragile committed Jul 3, 2019
1 parent fd820ca commit 8c2b1ad
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def main():

while processing_day < today:
with db.cursor() as cursor:
# Need to filter on "AND total_users > 0" since some installs
# run with a standby unused server with an empty db. This means
# that picking a recent entry for a given server is likely to
# under report. Filtering on total_users removes the standbys.
# It also filters out genuinely unused servers, but the value of
# aggregating these servers is limited.
query = """
SELECT
SUM(total_users) as 'total_users',
Expand All @@ -104,6 +110,7 @@ def main():
SELECT *, MAX(local_timestamp)
FROM stats
WHERE local_timestamp >= %s and local_timestamp < %s
AND total_users > 0
GROUP BY homeserver
) as s;
"""
Expand Down

0 comments on commit 8c2b1ad

Please # to comment.