fix(analytics): normalize seasonality month axis
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-15 16:06:53 +08:00
parent 5f3e88c9ca
commit 6a40d1e252
3 changed files with 24 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ from routes.monthly_routes import (
_resolve_monthly_period,
get_monthly_summary_data,
)
from routes.sales_routes import _filter_growth_payload
from routes.sales_routes import _filter_growth_payload, _sorted_valid_month_labels
from services.analysis_period_service import make_analysis_period, make_month_period
@@ -250,6 +250,17 @@ def test_growth_period_slices_every_series_and_recomputes_period_kpis():
assert period["end_month"] == "2026-05"
def test_sales_seasonality_month_axis_ignores_nan_and_invalid_values():
assert _sorted_valid_month_labels([
"2026-04",
float("nan"),
None,
"invalid",
"2025-12",
"2026-04-30",
]) == ["2025-12", "2026-04"]
def test_monthly_frontend_has_replayable_period_and_no_fixed_years():
script = (ROOT / "web/static/js/page-monthly-summary.js").read_text(encoding="utf-8")
route = (ROOT / "routes/monthly_routes.py").read_text(encoding="utf-8")