diff --git a/backend/check_features.py b/backend/check_features.py new file mode 100644 index 0000000..bd68e99 --- /dev/null +++ b/backend/check_features.py @@ -0,0 +1,36 @@ +#!/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)}") diff --git a/backend/routers/insights.py b/backend/routers/insights.py index aaba665..2b0a83f 100644 --- a/backend/routers/insights.py +++ b/backend/routers/insights.py @@ -348,7 +348,7 @@ async def analyze_pipeline(x_profile_id: Optional[str]=Header(default=None), ses if not access_calls['allowed']: logger.warning( f"[FEATURE-LIMIT] User {pid} would be blocked: " - f"ai_calls {access_calls['reason']} (used: {access_calls['used']}, limit: {access['limit']})" + f"ai_calls {access_calls['reason']} (used: {access_calls['used']}, limit: {access_calls['limit']})" ) # Old check (keep for now)