Fix Shorts 北京日配额 card to count enabled channels only.

Same disabled-Account double-count bug as yt-long: cap/uploaded ignored channel switches.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-09-16 21:50:26 -05:00
parent ca7724d3e4
commit 054fc1139d
2 changed files with 84 additions and 10 deletions

View File

@ -466,17 +466,20 @@ export default function ShortsPage() {
}, [status?.oauth_profiles, channels]);
const totals = useMemo(() => {
const uploaded = displayChannels.reduce((s, c) => s + (c.uploaded || 0), 0);
const scheduled = displayChannels.reduce((s, c) => s + (c.scheduled || 0), 0);
const recorded = displayChannels.reduce((s, c) => s + (c.recorded || 0), 0);
const pending = displayChannels.reduce((s, c) => s + (c.pending || 0), 0);
const recording = displayChannels.reduce((s, c) => s + (c.recording || 0), 0);
// Only **enabled** channels count toward 北京日配额 X/Y (same bug as yt-long).
const active = displayChannels.filter((c) => c.enabled !== false);
const uploaded = active.reduce((s, c) => s + (c.uploaded || 0), 0);
const scheduled = active.reduce((s, c) => s + (c.scheduled || 0), 0);
const recorded = active.reduce((s, c) => s + (c.recorded || 0), 0);
const pending = active.reduce((s, c) => s + (c.pending || 0), 0);
const recording = active.reduce((s, c) => s + (c.recording || 0), 0);
const used = uploaded;
const cap = displayChannels.reduce((s, c) => s + (c.daily_max || 9), 0);
const minTarget = displayChannels.filter((c) => c.enabled !== false).reduce((s, c) => s + (c.daily_min || 9), 0);
const gap = displayChannels
.filter((c) => c.enabled !== false)
.reduce((s, c) => s + (c.gap ?? Math.max(0, (c.daily_max || 9) - (c.uploaded || 0))), 0);
const cap = active.reduce((s, c) => s + (c.daily_max || 9), 0);
const minTarget = active.reduce((s, c) => s + (c.daily_min || 9), 0);
const gap = active.reduce(
(s, c) => s + (c.gap ?? Math.max(0, (c.daily_max || 9) - (c.uploaded || 0))),
0,
);
const queuedUpload = scheduled + recorded;
const pendingRecord = pending + recording;
return { uploaded, scheduled, recorded, pending, recording, queuedUpload, pendingRecord, used, cap, minTarget, gap };

View File

@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
"""Deploy Shorts enabled-only totals fix to dy + dylive."""
from __future__ import annotations
import sys
import time
from pathlib import Path
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
ROOT = Path(__file__).resolve().parents[1]
PASS = "Xiao4669805"
JUMP = "107.173.30.245"
DY = "108.174.50.68"
SH = r'''
set -e
install -D -m 644 /tmp/_shorts_page.tsx /opt/douyinWEB/frontend/src/app/shorts/page.tsx
grep -n "Only \*\*enabled\*\* channels" /opt/douyinWEB/frontend/src/app/shorts/page.tsx | head -3
cd /opt/douyinWEB/frontend && npm run build 2>&1 | tail -18
systemctl restart douyinweb-web
sleep 2
systemctl is-active douyinweb-web
echo HOST_DONE
'''
def wait(c, path, rounds=100):
out = ""
for i in range(rounds):
time.sleep(3)
_, o, _ = c.exec_command(f"tail -c 12000 {path} 2>/dev/null", timeout=15)
out = o.read().decode("utf-8", "replace")
if "HOST_DONE" in out and "EXIT:" in out:
return out
if i % 5 == 0:
print("poll", i, out[-100:].replace("\n", " | "), flush=True)
return out
def main():
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(JUMP, 22, "root", PASS, timeout=40, allow_agent=False, look_for_keys=False)
data = (ROOT / "frontend/src/app/shorts/page.tsx").read_bytes().replace(b"\r\n", b"\n")
sftp = c.open_sftp()
with sftp.file("/tmp/_shorts_page.tsx", "wb") as f:
f.write(data)
with sftp.file("/tmp/_shorts_fix.sh", "w") as f:
f.write(SH)
sftp.close()
print("===== dylive =====", flush=True)
c.exec_command(
"bash /tmp/_shorts_fix.sh > /tmp/_shorts_dylive.out 2>&1; echo EXIT:$? >> /tmp/_shorts_dylive.out",
timeout=1,
)
print(wait(c, "/tmp/_shorts_dylive.out")[-6000:], flush=True)
print("===== dy =====", flush=True)
c.exec_command(
f"SSHPASS={PASS} sshpass -e scp -o StrictHostKeyChecking=no /tmp/_shorts_page.tsx /tmp/_shorts_fix.sh root@{DY}:/tmp/ && "
f"SSHPASS={PASS} sshpass -e ssh -o StrictHostKeyChecking=no root@{DY} "
f"'bash /tmp/_shorts_fix.sh' > /tmp/_shorts_dy.out 2>&1; echo EXIT:$? >> /tmp/_shorts_dy.out",
timeout=1,
)
print(wait(c, "/tmp/_shorts_dy.out")[-6000:], flush=True)
c.close()
if __name__ == "__main__":
main()