fix: 探测整批代理加上总时限,学时翻页先判重再累加
This commit is contained in:
@@ -1065,9 +1065,9 @@ class StudySession:
|
||||
async def month_history_minutes(self, now: datetime | None = None) -> int:
|
||||
from euniv.client import (
|
||||
HISTORY_PAGE_SIZE,
|
||||
fold_month_minutes,
|
||||
history_items_from_payload,
|
||||
history_search_body,
|
||||
take_history_page,
|
||||
)
|
||||
from euniv.study_window import CN_TZ
|
||||
|
||||
@@ -1075,7 +1075,7 @@ class StudySession:
|
||||
year, month = current.year, current.month
|
||||
offset = 0
|
||||
total = 0
|
||||
first_mark: tuple | None = None
|
||||
seen: set[tuple] = set()
|
||||
for _ in range(50):
|
||||
resp = await self._api(
|
||||
"POST",
|
||||
@@ -1087,22 +1087,9 @@ class StudySession:
|
||||
if offset == 0:
|
||||
raise RuntimeError("学时历史没有获取到")
|
||||
return total
|
||||
if not rows:
|
||||
return total
|
||||
add, done = fold_month_minutes(rows, year, month)
|
||||
add, stop = take_history_page(rows, seen, year, month, HISTORY_PAGE_SIZE)
|
||||
total += add
|
||||
if done or len(rows) != HISTORY_PAGE_SIZE:
|
||||
return total
|
||||
mark = (
|
||||
len(rows),
|
||||
rows[0].get("studied_at"),
|
||||
rows[0].get("title"),
|
||||
rows[-1].get("studied_at"),
|
||||
rows[-1].get("title"),
|
||||
)
|
||||
if offset == 0:
|
||||
first_mark = mark
|
||||
elif mark == first_mark:
|
||||
if stop:
|
||||
return total
|
||||
offset += HISTORY_PAGE_SIZE
|
||||
return total
|
||||
|
||||
Reference in New Issue
Block a user