fix: 学时统一从我的学时页面按日期统计

This commit is contained in:
Nixevol
2026-11-19 02:44:04 +08:00
parent b9a332f791
commit a717ac714d
4 changed files with 159 additions and 99 deletions
+6 -13
View File
@@ -418,15 +418,6 @@ def _apply_hours_source(client, summary: dict, items: list | None = None) -> dic
data["hours_source"] = source
if source != "history":
return data
if items is None:
raw = client.study_history()
items = raw if isinstance(raw, list) else []
totals = history_hour_totals(items)
data["year_hours"] = totals["year"]
data["month_hours"] = totals["month"]
data["today_hours"] = totals["today"]
data["total_hours"] = totals["total"]
data["limited"] = False
walker = getattr(client, "month_history_minutes", None)
if callable(walker):
try:
@@ -434,14 +425,16 @@ def _apply_hours_source(client, summary: dict, items: list | None = None) -> dic
data["limited"] = bool(getattr(client, "history_limited", False))
except Exception:
data["limited"] = False
return data
if items is None:
raw = getattr(client, "study_history", None)
items = raw() if callable(raw) else []
totals = history_hour_totals(items if isinstance(items, list) else [])
data["month_hours"] = totals["month"]
return data
def _api_hour_fields(client) -> dict:
from admin.settings import hours_source_of
if hours_source_of() == "history":
return {}
reader = getattr(client, "hour_fields", None)
summary = reader() if reader is not None else client.home_summary()
return {