mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-10-03 16:48:28 -04:00
make count_monthly_users async synapse/handlers/auth.py
This commit is contained in:
parent
c507fa15ce
commit
7931393495
4 changed files with 46 additions and 38 deletions
|
@ -273,24 +273,24 @@ class DataStore(RoomMemberStore, RoomStore,
|
|||
This method should be refactored with count_daily_users - the only
|
||||
reason not to is waiting on definition of mau
|
||||
returns:
|
||||
int: count of current monthly active users
|
||||
defered: resolves to int
|
||||
"""
|
||||
def _count_monthly_users(txn):
|
||||
thirty_days_ago = int(self._clock.time_msec()) - (1000 * 60 * 60 * 24 * 30)
|
||||
sql = """
|
||||
SELECT COALESCE(count(*), 0) FROM (
|
||||
SELECT user_id FROM user_ips
|
||||
WHERE last_seen > ?
|
||||
GROUP BY user_id
|
||||
) u
|
||||
"""
|
||||
|
||||
thirty_days_ago = int(self._clock.time_msec()) - (1000 * 60 * 60 * 24 * 30)
|
||||
sql = """
|
||||
SELECT COALESCE(count(*), 0) FROM (
|
||||
SELECT user_id FROM user_ips
|
||||
WHERE last_seen > ?
|
||||
GROUP BY user_id
|
||||
) u
|
||||
"""
|
||||
try:
|
||||
txn = self.db_conn.cursor()
|
||||
txn.execute(sql, (thirty_days_ago,))
|
||||
count, = txn.fetchone()
|
||||
print "Count is %d" % (count,)
|
||||
return count
|
||||
finally:
|
||||
txn.close()
|
||||
|
||||
return self.runInteraction("count_monthly_users", _count_monthly_users)
|
||||
|
||||
def count_r30_users(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue