fix: 推送按序号只保留最新一帧,倒计时改用剩余秒数
This commit is contained in:
@@ -3,13 +3,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import threading
|
||||
from datetime import datetime
|
||||
|
||||
from euniv.study_window import month_key, window_open
|
||||
|
||||
|
||||
class StudyControlError(ValueError):
|
||||
"""任务控制参数不符合要求。"""
|
||||
_frame_lock = threading.Lock()
|
||||
_frames: dict[str, int] = {}
|
||||
|
||||
|
||||
def stamp_frame(employee_id: str, payload: dict) -> dict:
|
||||
key = (employee_id or "").strip()
|
||||
with _frame_lock:
|
||||
number = _frames.get(key, 0) + 1
|
||||
_frames[key] = number
|
||||
stamped = dict(payload)
|
||||
stamped["seq"] = number
|
||||
return stamped
|
||||
|
||||
|
||||
def start_now(account, now: datetime | None = None) -> None:
|
||||
@@ -179,4 +190,4 @@ def payload_for(employee_id: str) -> dict:
|
||||
live = dict((status.get("users") or {}).get(key) or {})
|
||||
if settle(account, live):
|
||||
db.commit()
|
||||
return assemble(account, live)
|
||||
return stamp_frame(key, assemble(account, live))
|
||||
|
||||
Reference in New Issue
Block a user