fix: pipeline typo and add features diagnostic script
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 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>
This commit is contained in:
Lars 2026-03-20 22:32:09 +01:00
parent 1298bd235f
commit 32d53b447d
2 changed files with 37 additions and 1 deletions

36
backend/check_features.py Normal file
View File

@ -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)}")

View File

@ -348,7 +348,7 @@ async def analyze_pipeline(x_profile_id: Optional[str]=Header(default=None), ses
if not access_calls['allowed']: if not access_calls['allowed']:
logger.warning( logger.warning(
f"[FEATURE-LIMIT] User {pid} would be blocked: " 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) # Old check (keep for now)