mirror of
https://github.com/zulip/zulip.git
synced 2026-07-15 21:03:26 +08:00
tornado: Remove normal-runtime query in the user pointers code path.
We still need to do an initial query to get the pointers for all users. (imported from commit 6ee991a648faf46539fd8676890dedb5f2003d05)
This commit is contained in:
parent
1a82741650
commit
053543e6eb
@ -57,8 +57,15 @@ def receive(user_profile_id, message):
|
||||
# to the cache.
|
||||
user_pointers = {}
|
||||
def get_user_pointer(user_profile_id):
|
||||
if user_pointers == {}:
|
||||
# Once, on startup, fill in the user_pointers table with
|
||||
# everyone's current pointers
|
||||
for u in UserProfile.objects.all():
|
||||
user_pointers[u.id] = u.pointer
|
||||
if user_profile_id not in user_pointers:
|
||||
user_pointers[user_profile_id] = UserProfile.objects.get(id=user_profile_id).pointer
|
||||
# This is a new user created since Tornado was started, so
|
||||
# they will have an initial pointer of -1.
|
||||
return -1
|
||||
return user_pointers[user_profile_id]
|
||||
|
||||
def set_user_pointer(user_profile_id, pointer):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user