不使用本地库,使用mariadb完成存储
This commit is contained in:
@@ -53,9 +53,9 @@ def generate_and_send_ranking(groupId, allContacts: dict):
|
|||||||
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
|
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
|
||||||
# 编写SQL查询来获取发言数量前20的用户
|
# 编写SQL查询来获取发言数量前20的用户
|
||||||
query = """
|
query = """
|
||||||
SELECT wx_id, count AS speech_count
|
SELECT wx_id, count AS speech_count
|
||||||
FROM speech_counts
|
FROM speech_counts
|
||||||
WHERE DDATE_FORMAT(DATE_SUB('2025-01-01', INTERVAL 1 DAY), '%Y-%m-%d')
|
WHERE date = %s
|
||||||
AND group_id = %s
|
AND group_id = %s
|
||||||
GROUP BY wx_id
|
GROUP BY wx_id
|
||||||
ORDER BY count DESC
|
ORDER BY count DESC
|
||||||
@@ -63,7 +63,7 @@ def generate_and_send_ranking(groupId, allContacts: dict):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# 执行查询并获取结果
|
# 执行查询并获取结果
|
||||||
cursor.execute(query, (groupId,))
|
cursor.execute(query, (yesterday,groupId,))
|
||||||
results = cursor.fetchall()
|
results = cursor.fetchall()
|
||||||
|
|
||||||
# 格式化输出字符串
|
# 格式化输出字符串
|
||||||
|
|||||||
Reference in New Issue
Block a user