fix(creator): 权限开通后的状态显示 + 同步范围可选可查
- 权限显示:实测今天 display/status 已变成 1,但 tip 是「数据正在更新中,请耐心等待」, 作品仍是 0 条。原逻辑只在未开通时显示提示条,于是会一边写着「数据已开通」一边列不出 作品,自相矛盾。现在只要后台有话要说就显示,并按状态区分措辞。 - 同步范围:原本写死 90 天,界面上既看不见也改不了。现在可选 7/30/90/180/365/730 天, 与后端校验上限一致。 - 新增 creator_account.last_sync_days,记录上次实际使用的范围 —— 否则界面只能说 「同步过了」,说不清覆盖的是哪一段。选择器也会对齐到它,避免上次同步 1 年、这次 点一下悄悄缩回 90 天。
This commit is contained in:
@@ -73,6 +73,9 @@ class CreatorAccount(MonitorBase):
|
||||
|
||||
last_checked_at: Mapped[Optional[int]] = mapped_column(BigInteger)
|
||||
last_synced_at: Mapped[Optional[int]] = mapped_column(BigInteger)
|
||||
# 上次同步用的时间范围(天,按发布时间)。当前展示的数据就是这个范围的产物 ——
|
||||
# 不记下来的话,界面只能说明"同步过了",说不清是哪一段。
|
||||
last_sync_days: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
last_error: Mapped[Optional[str]] = mapped_column(Text)
|
||||
|
||||
created_at: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
||||
|
||||
@@ -64,6 +64,7 @@ def _account_dict(account: CreatorAccount, note_count: int = 0) -> Dict[str, Any
|
||||
"permission_tip": account.permission_tip,
|
||||
"last_checked_at": account.last_checked_at,
|
||||
"last_synced_at": account.last_synced_at,
|
||||
"last_sync_days": account.last_sync_days,
|
||||
"last_error": account.last_error,
|
||||
"has_cookie": bool(account.cookie),
|
||||
"created_at": account.created_at,
|
||||
@@ -344,6 +345,7 @@ async def sync_account(
|
||||
)
|
||||
|
||||
account.last_synced_at = now
|
||||
account.last_sync_days = days
|
||||
account.last_error = None
|
||||
account.updated_at = now
|
||||
await refresh_permission(session, account)
|
||||
@@ -352,6 +354,7 @@ async def sync_account(
|
||||
return {
|
||||
"account_id": account_id,
|
||||
"fetched": len(collected),
|
||||
"days": days,
|
||||
"permission_status": account.permission_status,
|
||||
"permission_tip": account.permission_tip,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user