Spaces:
Paused
Paused
| """Final check after import""" | |
| import sys, os | |
| script_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| os.chdir(script_dir) | |
| if script_dir not in sys.path: | |
| sys.path.insert(0, script_dir) | |
| from app import create_app | |
| from extensions import db | |
| from models import EmployeeKpiValue | |
| from datetime import date | |
| from sqlalchemy import text | |
| app = create_app() | |
| with app.app_context(): | |
| records = EmployeeKpiValue.query.filter_by(week_start=date(2026, 7, 6)).count() | |
| cats = db.session.execute(text("SELECT COUNT(DISTINCT category) FROM employee_kpi_values WHERE week_start = '2026-07-06'")).scalar() | |
| users = db.session.execute(text("SELECT COUNT(DISTINCT user_id) FROM employee_kpi_values WHERE week_start = '2026-07-06'")).scalar() | |
| print(f"Week 2026-07-06: {records} records, {cats} categories, {users} users") | |
| result = db.session.execute(text("SELECT category, COUNT(*) as cnt FROM employee_kpi_values WHERE week_start = '2026-07-06' GROUP BY category ORDER BY category")) | |
| for row in result: | |
| print(f" {row.category:15s}: {row.cnt}") | |
| # Check that AVG Check is fixed | |
| avg_check = EmployeeKpiValue.query.filter_by( | |
| week_start=date(2026, 7, 6), | |
| category='Revenue', | |
| metric_name='AVG, Check in transaction' | |
| ).all() | |
| vals = [float(r.fact_value) for r in avg_check if r.fact_value] | |
| print(f"\nAVG Check in transaction: min={min(vals):.2f} max={max(vals):.2f} avg={sum(vals)/len(vals):.2f} (n={len(vals)})") | |
| # Check Eqosystem names are proper | |
| eqo = EmployeeKpiValue.query.filter_by( | |
| week_start=date(2026, 7, 6), | |
| category='Eqosystem' | |
| ).first() | |
| if eqo: | |
| name_hex = ' '.join(f'{ord(c):04x}' for c in eqo.metric_name[:20]) | |
| print(f"\nEqosystem sample metric: '{eqo.metric_name[:50]}' hex={name_hex}") | |