toxic-debug2
This commit is contained in:
@@ -35,12 +35,11 @@ async def messages_routing(msg, state):
|
|||||||
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
|
latest_toxic_message_id = await redis.get(f"toxic:{cid}")
|
||||||
pattern = f"toxic:{cid}:{uid}:*"
|
pattern = f"toxic:{cid}:{uid}:*"
|
||||||
scores = []
|
scores = []
|
||||||
found = await redis.scan_iter(pattern)
|
async for key in redis.scan_iter(pattern):
|
||||||
logger.debug(f'found {len(found)} messages')
|
|
||||||
for key in found:
|
|
||||||
scr = await redis.get(key)
|
scr = await redis.get(key)
|
||||||
if isinstance(scr, int):
|
if isinstance(scr, int):
|
||||||
scores.append(scr)
|
scores.append(scr)
|
||||||
|
logger.debug(f'found {len(scores)} messages')
|
||||||
toxic_score = math.floor(sum(scores)/len(scores)) if scores else 0
|
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)
|
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}"
|
msg_toxic_key = f"toxic:{cid}:{uid}:{scoring_msg_id}"
|
||||||
|
Reference in New Issue
Block a user