From 3e54789ee40dc87614c71e0c6d68e20dac78bc4d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Dec 2025 16:24:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=97=A5=E5=BF=97500=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题原因: - SQL查询中使用AS别名在SQLite Row对象转换时可能失败 修复方案: - 改为查询所有字段后在Python中进行字段映射 - 添加字段映射:execute_time → created_at - 添加字段映射:success_accounts → success_count - 添加字段映射:failed_accounts → failed_count - 添加字段映射:duration_seconds → duration 位置: database.py 第1661-1683行 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- database.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/database.py b/database.py index 369c8da..5f484e9 100755 --- a/database.py +++ b/database.py @@ -1663,27 +1663,24 @@ def get_schedule_execution_logs(schedule_id, limit=10): with db_pool.get_db() as conn: cursor = conn.cursor() cursor.execute(''' - SELECT - id, - schedule_id, - user_id, - schedule_name, - execute_time as created_at, - total_accounts, - success_accounts as success_count, - failed_accounts as failed_count, - total_items, - total_attachments, - total_screenshots, - duration_seconds as duration, - status, - error_message - FROM schedule_execution_logs + SELECT * FROM schedule_execution_logs WHERE schedule_id = ? ORDER BY execute_time DESC LIMIT ? ''', (schedule_id, limit)) - return [dict(row) for row in cursor.fetchall()] + + # 将数据库字段映射到前端期望的字段名 + logs = [] + for row in cursor.fetchall(): + log = dict(row) + # 字段映射 + log['created_at'] = log.get('execute_time') + log['success_count'] = log.get('success_accounts', 0) + log['failed_count'] = log.get('failed_accounts', 0) + log['duration'] = log.get('duration_seconds', 0) + logs.append(log) + + return logs def get_user_all_schedule_logs(user_id, limit=50):