Fix out of range bug
This commit is contained in:
parent
4a614bec65
commit
20c2bd71f8
1 changed files with 4 additions and 2 deletions
|
@ -408,11 +408,13 @@ def get_unread_count(rooms, user):
|
|||
.order_by().values('room')\
|
||||
.annotate(unread_count=Count('pk')).values('unread_count')
|
||||
|
||||
return UserRoom.objects\
|
||||
res = UserRoom.objects\
|
||||
.filter(user=user, room__isnull=True)\
|
||||
.annotate(
|
||||
unread_count=Coalesce(Subquery(mess, output_field=IntegerField()), 0),
|
||||
).values_list('unread_count', flat=True)[0]
|
||||
).values_list('unread_count', flat=True)
|
||||
|
||||
return res[0] if len(res) else 0
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Reference in a new issue