|
|
6 bulan lalu | |
|---|---|---|
| .. | ||
| README.md | 6 bulan lalu | |
| cleanup_selection_records.py | 6 bulan lalu | |
| config.ini | 6 bulan lalu | |
| config.ini.example | 6 bulan lalu | |
| requirements.txt | 6 bulan lalu | |
定时清理 buff_selection_request 表中的历史选品记录:
pip install -r requirements.txt
复制配置文件并修改数据库连接信息:
copy config.ini.example config.ini
编辑 config.ini:
[database]
host = localhost
port = 3306
user = root
password = your_password_here
database = buff
charset = utf8mb4
[script]
# 扫描间隔(秒),默认每 1 小时执行一次
interval_seconds = 3600
python cleanup_selection_records.py
==================================================
选品记录清理脚本已启动
清理周期: 每 3600 秒执行一次 (60 分钟)
清理规则: 每个用户保留最新的一条选品记录
启动时间: 2026-04-06 10:30:00
==================================================
[2026-04-06 10:30:01] 清理完成: 删除 15 条历史选品记录, 剩余 85 条
开始定时清理,每 3600 秒执行一次...
假设有以下选品记录(同一用户):
| id | user_id | created_at |
|---|---|---|
| 1 | 100 | 2026-04-01 |
| 5 | 100 | 2026-04-02 |
| 10 | 100 | 2026-04-03 |
| 20 | 100 | 2026-04-04 |
清理后只会保留 id=20 的记录,其他三条都会被删除。
| 配置项 | 默认值 | 说明 |
|---|---|---|
interval_seconds |
3600 | 清理任务执行间隔(秒) |