From 963865f4827a64946f696a86dc175721b6a8a8b3 Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 26 Sep 2024 20:11:46 +0300 Subject: [PATCH] toxic-debug2 --- handlers/messages_routing.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/handlers/messages_routing.py b/handlers/messages_routing.py index 16f6d82..bcd05d5 100644 --- a/handlers/messages_routing.py +++ b/handlers/messages_routing.py @@ -35,12 +35,11 @@ async def messages_routing(msg, state): latest_toxic_message_id = await redis.get(f"toxic:{cid}") pattern = f"toxic:{cid}:{uid}:*" scores = [] - found = await redis.scan_iter(pattern) - logger.debug(f'found {len(found)} messages') - for key in found: + async for key in redis.scan_iter(pattern): scr = await redis.get(key) if isinstance(scr, int): scores.append(scr) + logger.debug(f'found {len(scores)} messages') toxic_score = math.floor(sum(scores)/len(scores)) if scores else 0 scoring_msg_id = reply_msg.get("message_id", int(latest_toxic_message_id)) if reply_msg else int(latest_toxic_message_id) msg_toxic_key = f"toxic:{cid}:{uid}:{scoring_msg_id}"