wip commit - tests failing

This commit is contained in:
Neil Johnson 2018-08-03 17:55:50 +01:00
parent 5593ff6773
commit e10830e976
5 changed files with 66 additions and 53 deletions

View file

@ -86,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)
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
@ -95,25 +95,6 @@ class ClientIpStore(background_updates.BackgroundUpdateStore):
self._batch_row_update[key] = (user_agent, device_id, now)
@defer.inlineCallbacks
def _populate_monthly_active_users(self, user_id):
"""Checks on the state of monthly active user limits and optionally
add the user to the monthly active tables
Args:
user_id(str): the user_id to query
"""
store = self.hs.get_datastore()
if self.hs.config.limit_usage_by_mau:
is_user_monthly_active = yield store.is_user_monthly_active(user_id)
if is_user_monthly_active:
yield store.upsert_monthly_active_user(user_id)
else:
count = yield store.get_monthly_active_count()
if count < self.hs.config.max_mau_value:
yield store.upsert_monthly_active_user(user_id)
def _update_client_ips_batch(self):
def update():
to_update = self._batch_row_update