##// END OF EJS Templates
Do not load fav tags when need to only check notifications
neko259 -
r2056:dcf7666c default
parent child Browse files
Show More
@@ -241,6 +241,9 b' class DatabaseSettingsManager(SessionSet'
241 def tag_is_hidden(self, tag):
241 def tag_is_hidden(self, tag):
242 return self.settings.hidden_tags.filter(id=tag.id).exists()
242 return self.settings.hidden_tags.filter(id=tag.id).exists()
243
243
244 def get_user_settings(self):
245 return self.settings
246
244
247
245 def get_settings_manager(request) -> SettingsManager:
248 def get_settings_manager(request) -> SettingsManager:
246 """
249 """
@@ -34,7 +34,7 b' def get_notifications(context, settings_'
34 SETTING_LAST_NOTIFICATION_ID)
34 SETTING_LAST_NOTIFICATION_ID)
35
35
36 new_notifications_count = Notification.objects.get_notification_posts(
36 new_notifications_count = Notification.objects.get_notification_posts(
37 usernames=usernames, last=last_notification_id, fav_tags=fav_tags).only('id').count()
37 usernames=usernames, last=last_notification_id, user_settings=settings_manager.get_user_settings()).count()
38 context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count
38 context[CONTEXT_NEW_NOTIFICATIONS_COUNT] = new_notifications_count
39 context[CONTEXT_USERNAMES] = usernames
39 context[CONTEXT_USERNAMES] = usernames
40
40
@@ -25,11 +25,11 b' class Ban(models.Model):'
25
25
26
26
27 class NotificationManager(models.Manager):
27 class NotificationManager(models.Manager):
28 def get_notification_posts(self, usernames: list, last: int = None, fav_tags=None):
28 def get_notification_posts(self, usernames: list, last: int = None, user_settings=None):
29 lower_names = [username.lower() for username in usernames]
29 lower_names = [username.lower() for username in usernames]
30 posts = boards.models.post.Post.objects.filter(
30 posts = boards.models.post.Post.objects.filter(
31 Q(notification__name__in=lower_names) |
31 Q(notification__name__in=lower_names) |
32 (Q(thread__tags__in=fav_tags) & Q(opening=True))).distinct()
32 (Q(thread__tags__settings_as_fav=user_settings) & Q(opening=True))).distinct()
33 if last is not None:
33 if last is not None:
34 posts = posts.filter(id__gt=last)
34 posts = posts.filter(id__gt=last)
35 posts = posts.order_by('-id')
35 posts = posts.order_by('-id')
@@ -27,10 +27,8 b' class NotificationView(BaseBoardView):'
27 else:
27 else:
28 notification_usernames = [username]
28 notification_usernames = [username]
29
29
30 fav_tags = settings_manager.get_fav_tags()
31
32 posts = Notification.objects.get_notification_posts(
30 posts = Notification.objects.get_notification_posts(
33 usernames=notification_usernames, fav_tags=fav_tags)
31 usernames=notification_usernames, user_settings=settings_manager.get_user_settings())
34
32
35 if username is None:
33 if username is None:
36 last = posts.first()
34 last = posts.first()
General Comments 0
You need to be logged in to leave comments. Login now