feat: 心跳间隔改由每个用户自己设置
This commit is contained in:
@@ -423,15 +423,16 @@ def _interval_plan(ctype: str, intervals: dict, auto_mode: bool, params: dict) -
|
||||
return wait, declared, page_size
|
||||
|
||||
|
||||
def _current_intervals() -> tuple[dict, bool]:
|
||||
from admin.settings import heartbeat_intervals
|
||||
def _current_intervals(employee_id: str) -> tuple[dict, bool]:
|
||||
from euniv.db import SessionLocal
|
||||
from euniv.heartbeat import intervals_of
|
||||
from euniv.models import Account
|
||||
|
||||
cfg = heartbeat_intervals()
|
||||
return {
|
||||
"video": int(cfg["video"]),
|
||||
"document": int(cfg["document"]),
|
||||
"scorm": int(cfg["scorm"]),
|
||||
}, cfg["mode"] == "auto"
|
||||
with SessionLocal() as db:
|
||||
account = db.get(Account, (employee_id or "").strip())
|
||||
if account is None:
|
||||
return {"video": 30, "document": 120, "scorm": 120}, True
|
||||
return intervals_of(account)
|
||||
|
||||
|
||||
def _signal_stop(event: asyncio.Event | None) -> None:
|
||||
@@ -2048,7 +2049,7 @@ class AutoStudyWorker:
|
||||
if await wait_stop(random.uniform(2.0, 5.0), self._async_stop, hours.user_stop):
|
||||
return "stop"
|
||||
|
||||
intervals, auto_mode = await asyncio.to_thread(_current_intervals)
|
||||
intervals, auto_mode = await asyncio.to_thread(_current_intervals, employee_id)
|
||||
try:
|
||||
play_path = _play_path(kind, path, kid)
|
||||
session._referer = f"{EUNIV}{play_path}"
|
||||
|
||||
Reference in New Issue
Block a user