feat(计划): 评论计划勾选项 + 待评论计数

- ae_plan 新增 comment_mode(schema v26)
- 计划编辑器勾「评论计划」:账号显示待评论 N、隐藏视频未发/素材区,段内禁止发布素材
- list_accounts 带 comment_pending;comment.pending_counts 按账号汇总
- 计划列表显示评论待处理总数与「评论」标签
- 测试 test_comment/test_plan
This commit is contained in:
2026-10-31 10:12:34 +08:00
parent d5114dbf53
commit b9bee52878
11 changed files with 134 additions and 19 deletions
+21
View File
@@ -293,6 +293,27 @@ def pending_accounts():
for n, i, c in rows]
def pending_counts():
"""按账号汇总待评论(pending + failed),给资产/计划页面显示。
返回 `{"by_id": {account_id: n}, "by_name": {nickname: n}}`;两种键都查,
账号改名后 by_id 仍能对上。
"""
with _ctx():
rows = (db.session.query(CommentItem.account_id, CommentItem.account_name,
db.func.count(CommentItem.id))
.filter(CommentItem.status.in_(("pending", "failed")))
.group_by(CommentItem.account_id, CommentItem.account_name).all())
by_id, by_name = {}, {}
for aid, name, n in rows:
n = int(n or 0)
if aid:
by_id[aid] = by_id.get(aid, 0) + n
if name:
by_name[name] = by_name.get(name, 0) + n
return {"by_id": by_id, "by_name": by_name}
# ================== 原子领取 / 标记 ==================
def _reclaim_stale_locked():
cutoff = time.strftime("%Y-%m-%d %H:%M:%S",