douyinWEB/scripts/_diag_covers.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

55 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
import sqlite3
from app.config import settings
conn = sqlite3.connect(str(settings.sqlite_path))
conn.row_factory = sqlite3.Row
live = conn.execute(
"select room_id, last_anchor, last_status, active_session_id from rooms where last_status='live' limit 8"
).fetchall()
print("live_rooms", len(live))
for r in live:
print(" room", r["room_id"], r["last_anchor"], "sid", (r["active_session_id"] or "")[:8])
rows = conn.execute(
"""
select id, room_id, anchor_name,
substr(cover_path,1,100) as cp,
length(cover_path) as clen
from sessions order by started_at desc limit 12
"""
).fetchall()
print("recent_sessions")
for r in rows:
print(dict(r))
pc = conn.execute(
"""
select count(*) as c,
sum(case when trim(cover_url)='' then 1 else 0 end) as empty
from yt_assign_pool_urls
"""
).fetchone()
print("pool total", pc["c"], "empty_cover", pc["empty"])
s3 = conn.execute("select count(*) from sessions where cover_path like 'http%'").fetchone()[0]
empty = conn.execute(
"select count(*) from sessions where trim(coalesce(cover_path,''))=''"
).fetchone()[0]
print("sessions_s3", s3, "sessions_no_cover", empty)
# active live sessions missing cover
miss = conn.execute(
"""
select s.id, s.room_id, s.anchor_name, s.cover_path
from sessions s
join rooms r on r.active_session_id = s.id
where r.last_status='live' and trim(coalesce(s.cover_path,''))=''
limit 20
"""
).fetchall()
print("live_missing_cover", len(miss))
for r in miss:
print(dict(r))