feat: refine web analytics and history views

This commit is contained in:
Wyndham ARR
2026-08-02 12:56:22 +08:00
parent a891c0ae7a
commit 7e7470821b
37 changed files with 2088 additions and 361 deletions

View File

@@ -133,6 +133,9 @@ class CompanyReportCoordinator(Protocol):
) -> tuple[List[Dict[str, Any]], int]:
...
def list_month_counts(self) -> List[Dict[str, Any]]:
...
def get_job(self, job_id: str) -> Dict[str, Any]:
...
@@ -160,6 +163,9 @@ class UnavailableCompanyReportCoordinator:
) -> tuple[List[Dict[str, Any]], int]:
raise self._unavailable()
def list_month_counts(self) -> List[Dict[str, Any]]:
return []
def get_job(self, job_id: str) -> Dict[str, Any]:
raise self._unavailable()
@@ -292,6 +298,23 @@ class PersistentCompanyReportCoordinator:
page = states[offset : offset + limit]
return [self._public_locked(state) for state in page], total
def list_month_counts(self) -> List[Dict[str, Any]]:
with self._condition:
counts: Dict[str, int] = {}
for state in self._states_locked():
month_key = state.get("report_month")
if not isinstance(month_key, str):
continue
try:
validate_month(month_key)
except PortalError:
continue
counts[month_key] = counts.get(month_key, 0) + 1
return [
{"month_key": month_key, "company_count": counts[month_key]}
for month_key in sorted(counts, reverse=True)
]
def get_job(self, job_id: str) -> Dict[str, Any]:
with self._condition:
return self._public_locked(self._read_locked(job_id))