25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
import sqlite3
|
|
conn = sqlite3.connect('/home/hmo/MoFin/data/mofin.db')
|
|
print('=== portfolio_summary schema ===')
|
|
for r in conn.execute("SELECT sql FROM sqlite_master WHERE name='portfolio_summary'"):
|
|
print(r[0])
|
|
print()
|
|
print('=== latest row ===')
|
|
cur = conn.execute('SELECT * FROM portfolio_summary ORDER BY id DESC LIMIT 1')
|
|
cols = [d[0] for d in cur.description]
|
|
row = cur.fetchone()
|
|
for c, v in zip(cols, row):
|
|
print(f' {c} = {v}')
|
|
print()
|
|
print('=== decision_type distribution ===')
|
|
for r in conn.execute("SELECT decision_type, COUNT(*) FROM holding_strategies WHERE status='active' GROUP BY decision_type"):
|
|
print(f' {r[0]}: {r[1]}')
|
|
print()
|
|
print('=== full_analysis staleness ===')
|
|
for r in conn.execute("""
|
|
SELECT decision_type,
|
|
SUM(CASE WHEN full_analysis IS NULL OR LENGTH(full_analysis)<500 THEN 1 ELSE 0 END) as missing,
|
|
SUM(CASE WHEN LENGTH(full_analysis)>=500 THEN 1 ELSE 0 END) as has_fa,
|
|
COUNT(*) as total
|
|
FROM holding_strategies WHERE status='active' GROUP BY decision_type"""):
|
|
print(f' {r[0]}: missing={r[1]} has={r[2]} total={r[3]}') |