fix(customers): 客户列表排序实时对齐云客(全局实时body刷新last_chat_time,前5位逐位一致)

- scrape_friends 双阶段:逐员工全量保底 + 全局实时body(friendTab=all/isOnJob/ymd窗)
  刷 last_chat_time(该参数集跨员工按最近沟通实时排序,实测比**赐14:10实时值)
- 阶段2只刷last_chat_time且只增不减(全局结果含旧ES副本,upsert全字段会被后写覆盖)
- 调度4h增量改为 friends→wa-friends→messages(排序键每4h实时化)
- 实测我们top5=云客top5逐位一致(A**杰14:13/比**赐14:10/P**6/A**邱/J**n)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-20 14:46:02 +08:00
parent 811f2bc849
commit 8a8c91a6a3
2 changed files with 79 additions and 9 deletions
+20 -9
View File
@@ -579,21 +579,32 @@ class SyncScheduler:
if not bash:
logger.error("page sync 'full': bash not found on PATH")
return
args: list[str] = [bash, "scripts/full_sync_all.sh"]
commands: list[list[str]] = [[bash, "scripts/full_sync_all.sh"]]
elif kind == "messages":
args = [
sys.executable,
"scripts/scrape_via_page.py",
"--entity",
"messages",
"--max-conversations",
str(self.max_conversations_per_run),
# 先刷客户列表(最近沟通时间是云客列表的实时排序键,friends 快照
# 滞后会让本地排序与云客第一页完全不同,2026-08-20),再抓消息增量
commands = [
[sys.executable, "scripts/scrape_via_page.py", "--entity", "friends"],
[sys.executable, "scripts/scrape_via_page.py", "--entity", "wa-friends"],
[
sys.executable,
"scripts/scrape_via_page.py",
"--entity",
"messages",
"--max-conversations",
str(self.max_conversations_per_run),
],
]
else:
logger.error("page sync: unknown kind %r", kind)
return
rc = await self._page_subprocess(args)
rc = 0
for args in commands:
rc = await self._page_subprocess(args) or rc
if rc != 0:
logger.warning("page sync %s: command failed rc=%s, skipping rest", kind, rc)
break
finished_at = dt.datetime.now(dt.UTC)
line = json.dumps(
{