From de5368d9022b0d55b17ced24bd3e0eab369cf8f6 Mon Sep 17 00:00:00 2001 From: liuwei Date: Sat, 8 Feb 2025 10:30:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E4=BD=BF=E7=94=A8=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=BA=93=EF=BC=8C=E4=BD=BF=E7=94=A8mariadb=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- message_report/write_db.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/message_report/write_db.py b/message_report/write_db.py index 0830276..4d77c21 100644 --- a/message_report/write_db.py +++ b/message_report/write_db.py @@ -53,9 +53,9 @@ def generate_and_send_ranking(groupId, allContacts: dict): yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d') # 编写SQL查询来获取发言数量前20的用户 query = """ - SELECT wx_id, count AS speech_count + SELECT wx_id, count AS speech_count FROM speech_counts - WHERE DDATE_FORMAT(DATE_SUB('2025-01-01', INTERVAL 1 DAY), '%Y-%m-%d') + WHERE date = %s AND group_id = %s GROUP BY wx_id 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() # 格式化输出字符串