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>
This commit is contained in:
parent
1298bd235f
commit
32d53b447d
36
backend/check_features.py
Normal file
36
backend/check_features.py
Normal 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)}")
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user