feat: v0.8.x 功能更新与数据维护优化

- MAC地址格式统一为小写 xxxx-xxxx-xxxx,支持三种格式输入
- 更换设备MAC时自动清理OLT新发现列表中的冲突ONU记录
- 设备编辑新增场所类型字段(手动输入),区域改为下拉快速填充
- 编辑/更换设备时自动移除new_devices中同MAC的待入库记录
- 新增登录过期自动跳转(401拦截 + 过期提示)
- 新增关于页面(/about),支持Markdown渲染,管理员可在设置中编辑内容
- 新增device_status_history每日自动清理任务(保留30天)
- 更新README.md和about.md
This commit is contained in:
2026-04-24 08:53:28 +08:00
parent d222978ae4
commit eaabebbceb
15 changed files with 616 additions and 243 deletions
+16
View File
@@ -174,3 +174,19 @@ def aggregate_daily_snapshot():
return {'success': False, 'error': str(e), 'traceback': traceback.format_exc()}
finally:
db.close()
@celery_app.task
def cleanup_status_history():
"""清理 30 天前的设备状态历史记录(每天凌晨执行)"""
from app.models.device import DeviceStatusHistory
db = SessionLocal()
try:
cutoff = datetime.utcnow() - timedelta(days=30)
deleted = db.query(DeviceStatusHistory).filter(
DeviceStatusHistory.checked_at < cutoff
).delete(synchronize_session=False)
db.commit()
return {"deleted": deleted}
finally:
db.close()