Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 3b9bd0f

Browse files
committed
Fix: mess count might be 0
1 parent ca5c973 commit 3b9bd0f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controllers/peer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,12 @@ def num_answers():
274274
& (db.mchoice_answers.timestamp > parse(request.vars.start_time))
275275
).count(distinct=db.mchoice_answers.sid)
276276
r = redis.from_url(os.environ.get("REDIS_URI", "redis://redis:6379/0"))
277-
mess_count = int(r.hget(f"{auth.user.course_name}_state", "mess_count"))
277+
res = r.hget(f"{auth.user.course_name}_state", "mess_count")
278+
if res is not None:
279+
mess_count = int(res)
280+
else:
281+
mess_count = 0
282+
278283
return json.dumps({"count": acount, "mess_count": mess_count})
279284

280285

0 commit comments

Comments
 (0)