feat: refine web analytics and history views
This commit is contained in:
@@ -58,6 +58,7 @@ STATIC_ROUTES = {
|
||||
"/h5": ("h5.html", "text/html; charset=utf-8"),
|
||||
"/h5.html": ("h5.html", "text/html; charset=utf-8"),
|
||||
"/assets/styles.css": ("styles.css", "text/css; charset=utf-8"),
|
||||
"/assets/i18n.js": ("i18n.js", "text/javascript; charset=utf-8"),
|
||||
"/assets/app.js": ("app.js", "text/javascript; charset=utf-8"),
|
||||
"/assets/h5.css": ("h5.css", "text/css; charset=utf-8"),
|
||||
"/assets/h5.js": ("h5.js", "text/javascript; charset=utf-8"),
|
||||
@@ -70,6 +71,7 @@ LOGIN_STATIC_ROUTES = {
|
||||
"/login",
|
||||
"/login.html",
|
||||
"/assets/login.css",
|
||||
"/assets/i18n.js",
|
||||
"/assets/login.js",
|
||||
}
|
||||
LOGIN_DOCUMENT_ROUTES = {"/login", "/login.html"}
|
||||
@@ -345,6 +347,34 @@ class PortalApplication:
|
||||
offset=offset,
|
||||
),
|
||||
)
|
||||
if method == "GET" and route.path == "/api/history-months":
|
||||
combined: Dict[str, Dict[str, Any]] = {}
|
||||
for item in self._repository.list_history_month_counts():
|
||||
month_key = str(item.get("month_key", ""))
|
||||
validate_month(month_key)
|
||||
combined[month_key] = {
|
||||
"month_key": month_key,
|
||||
"daily_count": int(item.get("daily_count", 0) or 0),
|
||||
"monthly_count": int(item.get("monthly_count", 0) or 0),
|
||||
"company_count": 0,
|
||||
}
|
||||
for item in self._company_reports.list_month_counts():
|
||||
month_key = str(item.get("month_key", ""))
|
||||
validate_month(month_key)
|
||||
row = combined.setdefault(
|
||||
month_key,
|
||||
{
|
||||
"month_key": month_key,
|
||||
"daily_count": 0,
|
||||
"monthly_count": 0,
|
||||
"company_count": 0,
|
||||
},
|
||||
)
|
||||
row["company_count"] = int(item.get("company_count", 0) or 0)
|
||||
return Response.json(
|
||||
200,
|
||||
success([combined[key] for key in sorted(combined, reverse=True)]),
|
||||
)
|
||||
if method == "GET" and route.path == "/api/months":
|
||||
return Response.json(200, success(self._repository.list_months()))
|
||||
if method == "GET" and route.path == "/api/h5/months":
|
||||
|
||||
Reference in New Issue
Block a user