fix: 行动方案库统计卡片—补全API+overdue计算
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""Debug: verify period matching in kpis endpoint"""
|
||||
import datetime
|
||||
print(f"Current date: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print(f"period_str for month query: {datetime.datetime.now().strftime('%Y-%m')}")
|
||||
|
||||
# Run the failing tests with extra debugging
|
||||
import os, sys
|
||||
sys.path.insert(0, '/root/cma-management/backend')
|
||||
|
||||
# Patch summary to debug
|
||||
from app.api import dashboard as dashboard_mod
|
||||
original_summary = dashboard_mod.get_dashboard_summary
|
||||
|
||||
def debug_summary(role="ceo", period="month", db=None):
|
||||
from app.models import KPIDefinition
|
||||
from sqlalchemy import func
|
||||
if db:
|
||||
cnt = db.query(func.count(KPIDefinition.id)).filter(KPIDefinition.status == "active").scalar()
|
||||
print(f"[INTERNAL DEBUG] kpi_total query returns: {cnt}")
|
||||
all_k = db.query(KPIDefinition).all()
|
||||
print(f"[INTERNAL DEBUG] All KPIs: {[(k.id, k.kpi_code, k.status) for k in all_k]}")
|
||||
return original_summary(role=role, period=period, db=db)
|
||||
|
||||
dashboard_mod.get_dashboard_summary = debug_summary
|
||||
|
||||
# Now run the test sequence
|
||||
import pytest
|
||||
exit_code = pytest.main(["-v", "--tb=short",
|
||||
"tests/test_dashboard.py::TestDashboard::test_summary_empty",
|
||||
"tests/test_dashboard.py::TestDashboard::test_summary_with_data"])
|
||||
|
||||
dashboard_mod.get_dashboard_summary = original_summary
|
||||
sys.exit(exit_code)
|
||||
Reference in New Issue
Block a user