Fix out of range bug

This commit is contained in:
cuom1999 2021-12-20 18:55:26 -06:00
parent 4a614bec65
commit 20c2bd71f8

View file

@ -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