|
@@ -457,13 +457,13 @@ class AutoReplyCardsMonitor(AutoReplyCardsMonitorConst):
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
# 创建单个账号自动回复任务
|
|
# 创建单个账号自动回复任务
|
|
|
- async def create_auto_reply_single_account_task(self, gh_id, account_name):
|
|
|
|
|
|
|
+ async def create_auto_reply_single_account_task(self, gh_id, account_name, priority=0):
|
|
|
task_id = self.tool.generate_task_id(task_name="auto_reply", gh_id=gh_id)
|
|
task_id = self.tool.generate_task_id(task_name="auto_reply", gh_id=gh_id)
|
|
|
# 先插入 task, 再创建自动回复任务
|
|
# 先插入 task, 再创建自动回复任务
|
|
|
create_row = await self.mapper.create_auto_reply_task(task_id, gh_id)
|
|
create_row = await self.mapper.create_auto_reply_task(task_id, gh_id)
|
|
|
if create_row:
|
|
if create_row:
|
|
|
affected_rows = await self.mapper.insert_aigc_auto_reply_task(
|
|
affected_rows = await self.mapper.insert_aigc_auto_reply_task(
|
|
|
- task_id, gh_id
|
|
|
|
|
|
|
+ task_id, gh_id, priority
|
|
|
)
|
|
)
|
|
|
if not affected_rows:
|
|
if not affected_rows:
|
|
|
await self.log_service.log(
|
|
await self.log_service.log(
|
|
@@ -515,8 +515,28 @@ class AutoReplyCardsMonitor(AutoReplyCardsMonitorConst):
|
|
|
)
|
|
)
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
- for account in account_list:
|
|
|
|
|
- account_name = getattr(account, "公众号名", None)
|
|
|
|
|
|
|
+ # 按 UV 降序排列 + 分档分配优先级
|
|
|
|
|
+ sorted_accounts = sorted(
|
|
|
|
|
+ (
|
|
|
|
|
+ (getattr(a, "公众号名", None), getattr(a, "uv", 0) or 0)
|
|
|
|
|
+ for a in account_list
|
|
|
|
|
+ ),
|
|
|
|
|
+ key=lambda x: x[1],
|
|
|
|
|
+ reverse=True,
|
|
|
|
|
+ )
|
|
|
|
|
+ tiered_accounts = self.tool.assign_priority_tiers(sorted_accounts)
|
|
|
|
|
+
|
|
|
|
|
+ top_n = min(10, len(tiered_accounts))
|
|
|
|
|
+ await self.log_service.log(
|
|
|
|
|
+ contents={
|
|
|
|
|
+ "task": "auto_reply_cards_monitor",
|
|
|
|
|
+ "function": "follow_gzh_task",
|
|
|
|
|
+ "status": "info",
|
|
|
|
|
+ "message": f"账号按UV分档完成, total={len(tiered_accounts)}, top{top_n}={[(name, uv, p) for name, uv, p in tiered_accounts[:top_n]]}",
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ for account_name, uv, priority in tiered_accounts[:1]:
|
|
|
if not account_name:
|
|
if not account_name:
|
|
|
await self.log_service.log(
|
|
await self.log_service.log(
|
|
|
contents={
|
|
contents={
|
|
@@ -585,7 +605,8 @@ class AutoReplyCardsMonitor(AutoReplyCardsMonitorConst):
|
|
|
)
|
|
)
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
- await self.create_auto_reply_single_account_task(gh_id, account_name)
|
|
|
|
|
|
|
+ print(gh_id, account_name, uv, priority)
|
|
|
|
|
+ await self.create_auto_reply_single_account_task(gh_id, account_name, priority)
|
|
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
await self.log_service.log(
|
|
await self.log_service.log(
|