Publish King campaign report (manual update)

This commit is contained in:
SHAREit
2026-09-01 15:23:12 +08:00
parent 9e152bd0bf
commit aab3f279d8
2 changed files with 14 additions and 0 deletions
+1
View File
@@ -257,6 +257,7 @@ function renderPerformance(){
if(sands.fetched_at)notes.push(`Sands Cost 抓取于 ${esc(String(sands.fetched_at).replace('T',' '))},不随每日自动更新`);
if(sands.scope)notes.push(`Cost 范围:${esc(sands.scope)}`);
if(sands.carried_over)notes.push('<b style="color:#b45309">Cost 沿用上次抓取值,需本地重新抓取才会更新</b>');
if(sands.stale)notes.push(`<b style="color:#b42318">Cost 数据滞后:抓取于 ${esc(sands.fetched_date||'')},周期到 ${esc((report.period||{}).end||'')},滞后约 ${num(sands.lag_days)} 天,GP 会偏高</b>`);
if(Array.isArray(sands.missing_pkgs)&&sands.missing_pkgs.length)
notes.push(`<b style="color:#b42318">Cost 不完整,缺少包:${esc(sands.missing_pkgs.join(', '))}</b>`);
}
+13
View File
@@ -458,6 +458,19 @@ def build_payload(now):
except Exception as error:
print(f" Target 读取失败({error});请把该表共享给服务账号或开放链接查看")
sands = load_sands_cost()
# 判断 Cost 是否滞后于数据周期
if sands and sands.get("fetched_at"):
try:
fetched = datetime.fromisoformat(sands["fetched_at"]).date()
except ValueError:
fetched = None
if fetched:
lag = (end_date - fetched).days + 1
sands["fetched_date"] = fetched.isoformat()
sands["lag_days"] = max(0, lag)
sands["stale"] = lag > 0
if sands["stale"]:
print(f" 警告:Sands Cost 抓取于 {fetched},可能未覆盖到 {end_date},滞后约 {lag} 天")
# 消耗表里可能出现 Cost_Client 未覆盖的 Campaign,一并纳入
for key, _day in wide_costs: