查询数据1

This commit is contained in:
lhx
2025-09-29 11:58:56 +08:00
parent 2e735e587b
commit 242fedd37e
5 changed files with 129 additions and 24 deletions

View File

@@ -81,6 +81,24 @@ class TaskScheduler:
except Exception as e:
logger.error(f"设置系统定时任务失败: {e}")
# 设置测试任务
try:
existing_job = self.scheduler.get_job("test_task")
if not existing_job:
# 添加每天每小时重置today_updated字段的任务
self.scheduler.add_job(
reset_today_updated_task,
'cron',
id='test_task',
hour='*',
minute=0,
second=0,
name='测试任务'
)
logger.info("系统定时任务:测试任务已添加")
except Exception as e:
logger.error(f"设置测试任务失败: {e}")
def add_cron_job(self, func, job_id: str, **kwargs):
"""添加cron定时任务"""
return self.scheduler.add_job(func, 'cron', id=job_id, **kwargs)
@@ -142,6 +160,7 @@ def reset_today_updated_task():
logger.info("开始执行每日重置账号更新状态任务")
# 更新所有账号的today_updated字段为0
updated_need_count = db.query(Account).filter(Account.today_updated == 1).count()
updated_count = db.query(Account).update({Account.today_updated: 0})
db.commit()