mitai-jinkendo/backend/check_features.py
Lars 32d53b447d
All checks were successful
Deploy Development / deploy (push) Successful in 34s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
fix: pipeline typo and add features diagnostic script
- Fix NameError in insights.py pipeline endpoint (access -> access_calls)
- Add check_features.py diagnostic script for debugging

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 22:32:09 +01:00

37 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Quick diagnostic script to check features table."""
from db import get_db, get_cursor
with get_db() as conn:
cur = get_cursor(conn)
print("\n=== FEATURES TABLE ===")
cur.execute("SELECT id, name, active, limit_type, reset_period FROM features ORDER BY id")
features = cur.fetchall()
if not features:
print("❌ NO FEATURES FOUND! Migration failed!")
else:
for r in features:
print(f" {r['id']:30} {r['name']:40} active={r['active']} type={r['limit_type']:8} reset={r['reset_period']}")
print(f"\nTotal features: {len(features)}")
print("\n=== USER_FEATURE_USAGE (recent) ===")
cur.execute("""
SELECT profile_id, feature_id, usage_count, reset_at
FROM user_feature_usage
ORDER BY updated DESC
LIMIT 10
""")
usages = cur.fetchall()
if not usages:
print(" (no usage records yet)")
else:
for r in usages:
print(f" {r['profile_id'][:8]}... -> {r['feature_id']:30} used={r['usage_count']} reset_at={r['reset_at']}")
print(f"\nTotal usage records: {len(usages)}")