mirror of
https://github.com/element-hq/synapse
synced 2024-09-12 03:35:10 +00:00
Reduce activity timer granularity to avoid too many quick updates (SYN-247)
This commit is contained in:
parent
72d8406409
commit
ed008e85a8
1 changed files with 8 additions and 0 deletions
|
@ -33,6 +33,10 @@ logger = logging.getLogger(__name__)
|
|||
metrics = synapse.metrics.get_metrics_for(__name__)
|
||||
|
||||
|
||||
# Don't bother bumping "last active" time if it differs by less than 60 seconds
|
||||
LAST_ACTIVE_GRANULARITY = 60*1000
|
||||
|
||||
|
||||
# TODO(paul): Maybe there's one of these I can steal from somewhere
|
||||
def partition(l, func):
|
||||
"""Partition the list by the result of func applied to each element."""
|
||||
|
@ -282,6 +286,10 @@ class PresenceHandler(BaseHandler):
|
|||
if now is None:
|
||||
now = self.clock.time_msec()
|
||||
|
||||
prev_state = self._get_or_make_usercache(user)
|
||||
if now - prev_state.state.get("last_active", 0) < LAST_ACTIVE_GRANULARITY:
|
||||
return
|
||||
|
||||
self.changed_presencelike_data(user, {"last_active": now})
|
||||
|
||||
def changed_presencelike_data(self, user, state):
|
||||
|
|
Loading…
Reference in a new issue