mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
Exclude dormant users from buddy list queries.
If a user has not shown activity in two weeks, we exclude them from the buddy list. This should help performance for large realms and mobile clients.
This commit is contained in:
@@ -1430,6 +1430,12 @@ class UserPresence(models.Model):
|
||||
|
||||
return UserPresence.get_status_dicts_for_query(query, mobile_user_ids)
|
||||
|
||||
@staticmethod
|
||||
def exclude_old_users(query):
|
||||
# type: (QuerySet) -> QuerySet
|
||||
two_weeks_ago = timezone.now() - datetime.timedelta(weeks=2)
|
||||
return query.filter(timestamp__gte=two_weeks_ago)
|
||||
|
||||
@staticmethod
|
||||
def get_status_dict_by_realm(realm_id):
|
||||
# type: (int) -> DefaultDict[Any, Dict[Any, Any]]
|
||||
@@ -1437,7 +1443,11 @@ class UserPresence(models.Model):
|
||||
user_profile__realm_id=realm_id,
|
||||
user_profile__is_active=True,
|
||||
user_profile__is_bot=False
|
||||
).values(
|
||||
)
|
||||
|
||||
query = UserPresence.exclude_old_users(query)
|
||||
|
||||
query = query.values(
|
||||
'client__name',
|
||||
'status',
|
||||
'timestamp',
|
||||
|
||||
Reference in New Issue
Block a user