mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
Don't perform an additional SELECT just to get a count for statsd.
len() uses the QuerySet as an iterator, which performs a SELECT for all of those rows. (imported from commit d362fef375c5270bedade2a7b50aea7b1a559d1e)
This commit is contained in:
@@ -846,11 +846,11 @@ def update_message_flags(user_profile, operation, flag, messages, all):
|
|||||||
message__id__in=messages)
|
message__id__in=messages)
|
||||||
|
|
||||||
if operation == 'add':
|
if operation == 'add':
|
||||||
msgs.update(flags=F('flags').bitor(flagattr))
|
count = msgs.update(flags=F('flags').bitor(flagattr))
|
||||||
elif operation == 'remove':
|
elif operation == 'remove':
|
||||||
msgs.update(flags=F('flags').bitand(~flagattr))
|
count = msgs.update(flags=F('flags').bitand(~flagattr))
|
||||||
|
|
||||||
statsd.incr("flags.%s.%s" % (flag, operation), len(msgs))
|
statsd.incr("flags.%s.%s" % (flag, operation), count)
|
||||||
|
|
||||||
def process_user_presence_event(event):
|
def process_user_presence_event(event):
|
||||||
user_profile = get_user_profile_by_id(event["user_profile_id"])
|
user_profile = get_user_profile_by_id(event["user_profile_id"])
|
||||||
|
|||||||
Reference in New Issue
Block a user