mirror of https://github.com/zulip/zulip.git
actions: Use better query for active_mobile_push_notification.
This commit is contained in:
parent
887d20795f
commit
2e6aaf3215
|
@ -3570,10 +3570,10 @@ def do_update_pointer(user_profile: UserProfile, client: Client,
|
|||
# when we drop support for the old Android app entirely.
|
||||
app_message_ids = UserMessage.objects.filter(
|
||||
user_profile=user_profile,
|
||||
flags=UserMessage.flags.active_mobile_push_notification,
|
||||
message__id__gt=prev_pointer,
|
||||
message__id__lte=pointer).extra(where=[
|
||||
UserMessage.where_unread(),
|
||||
UserMessage.where_active_push_notification(),
|
||||
]).values_list("message_id", flat=True)
|
||||
|
||||
UserMessage.objects.filter(user_profile=user_profile,
|
||||
|
@ -3611,8 +3611,9 @@ def do_mark_all_as_read(user_profile: UserProfile, client: Client) -> int:
|
|||
|
||||
all_push_message_ids = UserMessage.objects.filter(
|
||||
user_profile=user_profile,
|
||||
flags=UserMessage.flags.active_mobile_push_notification,
|
||||
).values_list("message_id", flat=True)
|
||||
).extra(
|
||||
where=[UserMessage.where_active_push_notification()],
|
||||
).values_list("message_id", flat=True)[0:10000]
|
||||
do_clear_mobile_push_notifications_for_ids(user_profile, all_push_message_ids)
|
||||
|
||||
return count
|
||||
|
@ -3660,8 +3661,8 @@ def do_clear_mobile_push_notifications_for_ids(user_profile: UserProfile,
|
|||
message_ids: List[int]) -> None:
|
||||
for user_message in UserMessage.objects.filter(
|
||||
message_id__in=message_ids,
|
||||
flags=UserMessage.flags.active_mobile_push_notification,
|
||||
user_profile=user_profile):
|
||||
user_profile=user_profile).extra(
|
||||
where=[UserMessage.where_active_push_notification()]):
|
||||
event = {
|
||||
"user_profile_id": user_profile.id,
|
||||
"message_id": user_message.message_id,
|
||||
|
|
|
@ -1559,6 +1559,11 @@ class AbstractUserMessage(models.Model):
|
|||
# will generate a query involving `flags & 2 = 2`, which doesn't match our index.
|
||||
return 'flags & 2 <> 0'
|
||||
|
||||
@staticmethod
|
||||
def where_active_push_notification() -> str:
|
||||
# See where_starred for documentation.
|
||||
return 'flags & 4096 <> 0'
|
||||
|
||||
def flags_list(self) -> List[str]:
|
||||
flags = int(self.flags)
|
||||
return self.flags_list_for_flags(flags)
|
||||
|
|
Loading…
Reference in New Issue