fix(application): 修复普通用户接收消息数量统计错误
- 移除了对 user_id == 1 的特殊判断,统一了消息数量统计逻辑 - 优化了代码结构,提高了代码的可读性和维护性
This commit is contained in:
@@ -17,9 +17,6 @@ def event_stream(user_id):
|
||||
last_db_change_time = cache.get('last_db_change_time', 0)
|
||||
# 只有当数据库发生变化时才检查总数
|
||||
if last_db_change_time and last_db_change_time > last_sent_time:
|
||||
if user_id == 1:
|
||||
count = MessageCenterTargetUser.objects.filter(is_read=False).count()
|
||||
else:
|
||||
count = MessageCenterTargetUser.objects.filter(users=user_id, is_read=False).count()
|
||||
yield f"data: {count}\n\n"
|
||||
last_sent_time = time.time()
|
||||
|
||||
Reference in New Issue
Block a user