fix(计划): 定时触发补 app context;账号状态加检测时间与历史记录
- _fire 内调用 run_plan(修复 18:00 Working outside application context,无运行记录) - device_account 新增 status_checked_at;新表 account_status_log(schema v23) - 每次检测/手改留痕;资产表显示检测时间 + 「记录」弹窗 - API /api/af/account_status_logs;备份标签/文档/测试同步
This commit is contained in:
@@ -565,6 +565,8 @@ class DeviceAccount(db.Model):
|
||||
# 账号状态(正常 / 账号异常 / 限流…):资产管理里可手改;任务里「读取文字」
|
||||
# 存到变量 `account_status` 时会自动回写这一列(见 tasks/generic/task.py)。
|
||||
account_status = db.Column(db.String(80), default="")
|
||||
# 最近一次「检测到状态」的时间(历史明细在 account_status_log)
|
||||
status_checked_at = db.Column(db.String(20), default="")
|
||||
created_at = db.Column(db.String(20), default="")
|
||||
updated_at = db.Column(db.String(20), default="")
|
||||
|
||||
@@ -577,12 +579,43 @@ class DeviceAccount(db.Model):
|
||||
"can_post_video": bool(self.can_post_video),
|
||||
"bio": self.bio or "", "note": self.note or "",
|
||||
"account_status": self.account_status or "",
|
||||
"status_checked_at": self.status_checked_at or "",
|
||||
"created_at": self.created_at or "", "updated_at": self.updated_at or ""}
|
||||
|
||||
def __repr__(self):
|
||||
return f"<DeviceAccount {self.device_name} {self.nickname}>"
|
||||
|
||||
|
||||
class AccountStatusLog(db.Model):
|
||||
"""账号状态检测记录:每次检测(或手动修改)追加一行。
|
||||
|
||||
资产页「账号状态」列只显示最新值;点「记录」看这个账号的历史:
|
||||
时间 + 状态 + 设备 + 来源(计划运行/任务运行/手动修改)。
|
||||
"""
|
||||
__tablename__ = "account_status_log"
|
||||
id = db.Column(db.String(32), primary_key=True)
|
||||
account_id = db.Column(db.String(32), default="", index=True)
|
||||
nickname = db.Column(db.String(80), default="", index=True)
|
||||
device_name = db.Column(db.String(80), default="")
|
||||
serial = db.Column(db.String(120), default="")
|
||||
status = db.Column(db.String(80), default="")
|
||||
source = db.Column(db.String(40), default="")
|
||||
run_id = db.Column(db.String(32), default="", index=True)
|
||||
detected_at = db.Column(db.String(20), default="", index=True)
|
||||
created_at = db.Column(db.String(20), default="")
|
||||
|
||||
def to_dict(self):
|
||||
return {"id": self.id, "account_id": self.account_id or "",
|
||||
"nickname": self.nickname or "", "device_name": self.device_name or "",
|
||||
"serial": self.serial or "", "status": self.status or "",
|
||||
"source": self.source or "", "run_id": self.run_id or "",
|
||||
"detected_at": self.detected_at or "",
|
||||
"created_at": self.created_at or ""}
|
||||
|
||||
def __repr__(self):
|
||||
return f"<AccountStatusLog {self.nickname} {self.status} @{self.detected_at}>"
|
||||
|
||||
|
||||
class VideoPlan(db.Model):
|
||||
"""视频发布计划:账号 × 发布日期 × 编号 → 一个视频素材 + 一条标题 + 发布结果。
|
||||
|
||||
@@ -1043,6 +1076,8 @@ SCHEMA_MIGRATIONS = [
|
||||
"「读取文字」写变量 account_status 时自动回写,用于创作者中心/异常检测)", None),
|
||||
(22, "应用管理·自动下载:新增 apk_source 表(下载直链、检查间隔、上次检查结果)",
|
||||
None),
|
||||
(23, "账号状态历史:device_account 新增 status_checked_at(最近检测时间);"
|
||||
"新增 account_status_log(每次检测/手改追加一行:状态/时间/设备/来源)", None),
|
||||
]
|
||||
|
||||
# 当前 schema 版本(备份/恢复用它判断新旧,也写进 app_meta.schema_version)
|
||||
|
||||
Reference in New Issue
Block a user