Move unread chat count to one request
This commit is contained in:
parent
a7f7aab444
commit
bddb00050a
5 changed files with 40 additions and 48 deletions
|
@ -16,6 +16,7 @@ from judge.models.choices import ACE_THEMES, MATH_ENGINES_CHOICES, TIMEZONE
|
|||
from judge.models.runtime import Language
|
||||
from judge.ratings import rating_class
|
||||
|
||||
|
||||
__all__ = ["Organization", "Profile", "OrganizationRequest", "Friend"]
|
||||
|
||||
|
||||
|
@ -242,6 +243,12 @@ class Profile(models.Model):
|
|||
}
|
||||
return self.notifications.filter(**query).count()
|
||||
|
||||
@cached_property
|
||||
def count_unread_chat_boxes(self):
|
||||
from chat_box.utils import get_unread_boxes
|
||||
|
||||
return get_unread_boxes(self)
|
||||
|
||||
_pp_table = [pow(settings.DMOJ_PP_STEP, i) for i in range(settings.DMOJ_PP_ENTRIES)]
|
||||
|
||||
def calculate_points(self, table=_pp_table):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue