This commit is contained in:
liuwei
2025-02-06 09:56:58 +08:00
parent cfe495e201
commit fa2a9fd762

View File

@@ -27,7 +27,7 @@ def write_to_db():
# 遍历Redis中所有与昨天日期相关的key并写入数据库
for key in r.keys(f"*:*:{yesterday}:count"):
print('user key' + key)
# print('user key' + key)
parts = key.decode('utf-8').split(':')
group_id, wx_id, _date = parts[0], parts[1], parts[2] # _date应该是yesterday但这里为了完整性还是保留
count = int(r.hget(key, 'count')) if isinstance(r.hget(key, 'count'), bytes) else 0 # 处理可能的None或空值情况
@@ -67,7 +67,7 @@ def generate_and_send_ranking(groupId, allContacts: dict):
ranking_str += f"{rank}. {allContacts[username]}: {speech_count} 次发言\n"
# 关闭数据库连接
conn.close()
print(ranking_str)
# 这里我们没有实际“发送”排名,只是返回字符串
# 如果需要发送,可以在此添加发送逻辑
return ranking_str