diff options
author | Neil Johnson <neil@matrix.org> | 2018-08-08 12:44:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 12:44:15 +0000 |
commit | 990fe9fc23245d193233b88f924e905ee4b2de3d (patch) | |
tree | bc5aed8a97fdd22845ec48e5c84fea981f812003 /synapse/storage/client_ips.py | |
parent | Merge pull request #3658 from matrix-org/rav/fix_event_persisted_position_met... (diff) | |
parent | typos (diff) | |
download | synapse-990fe9fc23245d193233b88f924e905ee4b2de3d.tar.xz |
Merge pull request #3633 from matrix-org/neilj/mau_tracker
API for monthly_active_users table
Diffstat (limited to 'synapse/storage/client_ips.py')
-rw-r--r-- | synapse/storage/client_ips.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/synapse/storage/client_ips.py b/synapse/storage/client_ips.py index b8cefd43d6..2489527f2c 100644 --- a/synapse/storage/client_ips.py +++ b/synapse/storage/client_ips.py @@ -35,6 +35,7 @@ LAST_SEEN_GRANULARITY = 120 * 1000 class ClientIpStore(background_updates.BackgroundUpdateStore): def __init__(self, db_conn, hs): + self.client_ip_last_seen = Cache( name="client_ip_last_seen", keylen=4, @@ -74,6 +75,7 @@ class ClientIpStore(background_updates.BackgroundUpdateStore): "before", "shutdown", self._update_client_ips_batch ) + @defer.inlineCallbacks def insert_client_ip(self, user_id, access_token, ip, user_agent, device_id, now=None): if not now: @@ -84,7 +86,7 @@ class ClientIpStore(background_updates.BackgroundUpdateStore): last_seen = self.client_ip_last_seen.get(key) except KeyError: last_seen = None - + yield self.populate_monthly_active_users(user_id) # Rate-limited inserts if last_seen is not None and (now - last_seen) < LAST_SEEN_GRANULARITY: return |