douyinWEB/scripts/_check_room_dedup.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 22:42:40 -05:00

52 lines
1.6 KiB
Python

"""Check duplicate uploads per channel in shorts_jobs on server."""
import paramiko
HOST = "107.173.30.245"
USER = "root"
PASSWORD = "Xiao4669805"
REMOTE_SCRIPT = """\
import sqlite3
conn = sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db')
q1 = conn.execute(
"SELECT channel_id, room_id, push_date, COUNT(*) as cnt FROM shorts_jobs"
" WHERE status NOT IN ('failed','skipped')"
" AND channel_id IS NOT NULL AND channel_id != ''"
" AND room_id IS NOT NULL AND room_id != ''"
" GROUP BY channel_id, room_id, push_date HAVING cnt > 1 ORDER BY cnt DESC LIMIT 30"
).fetchall()
print('channel+room+day duplicates:', len(q1))
for r in q1:
print(' ', r[0][:14], r[1], r[2], 'x'+str(r[3]))
q2 = conn.execute(
"SELECT channel_id, room_id, COUNT(*) as cnt FROM shorts_jobs"
" WHERE status NOT IN ('failed','skipped')"
" AND channel_id IS NOT NULL AND channel_id != ''"
" AND room_id IS NOT NULL AND room_id != ''"
" GROUP BY channel_id, room_id HAVING cnt > 1 ORDER BY cnt DESC LIMIT 20"
).fetchall()
print('channel+room history duplicates:', len(q2))
for r in q2:
print(' ', r[0][:14], r[1], 'x'+str(r[2]))
conn.close()
"""
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, 22, USER, PASSWORD, timeout=15, allow_agent=False, look_for_keys=False)
sftp = c.open_sftp()
with sftp.open("/tmp/_check_dedup.py", "w") as f:
f.write(REMOTE_SCRIPT)
sftp.close()
_, out, err = c.exec_command("python3 /tmp/_check_dedup.py", timeout=20)
print(out.read().decode("utf-8", "replace"))
e = err.read().decode("utf-8", "replace")
if e:
print("ERR:", e[:800])
c.close()