mirror of
https://github.com/prdlk/omarchy-beeper.git
synced 2026-11-02 21:22:49 +00:00
refactor: inline the monotonic clock helper
This commit is contained in:
1 parent
9f55f2585c
commit
11624ce59c
1 file changed
+2
-6
+2
-6
@@ -193,7 +193,7 @@ def unread_chats(token: str, cap: int = FETCH_CAP, budget: float = 0.0) -> tuple
|
|||||||
seen: set[str] = set()
|
seen: set[str] = set()
|
||||||
cursor = ""
|
cursor = ""
|
||||||
truncated = False
|
truncated = False
|
||||||
deadline = (_now() + budget) if budget > 0 else 0.0
|
deadline = (time.monotonic() + budget) if budget > 0 else 0.0
|
||||||
while True:
|
while True:
|
||||||
params = {
|
params = {
|
||||||
"unreadOnly": True,
|
"unreadOnly": True,
|
||||||
@@ -225,7 +225,7 @@ def unread_chats(token: str, cap: int = FETCH_CAP, budget: float = 0.0) -> tuple
|
|||||||
cursor = str(data.get("oldestCursor") or "")
|
cursor = str(data.get("oldestCursor") or "")
|
||||||
if not data.get("hasMore") or not cursor or not items:
|
if not data.get("hasMore") or not cursor or not items:
|
||||||
break
|
break
|
||||||
if deadline and _now() >= deadline:
|
if deadline and time.monotonic() >= deadline:
|
||||||
truncated = True
|
truncated = True
|
||||||
break
|
break
|
||||||
out.sort(key=lambda chat: (_ts(chat.get("lastActivity")), str(chat.get("id"))), reverse=True)
|
out.sort(key=lambda chat: (_ts(chat.get("lastActivity")), str(chat.get("id"))), reverse=True)
|
||||||
@@ -320,7 +320,3 @@ def _ts(value: object) -> float:
|
|||||||
if parsed.tzinfo is None:
|
if parsed.tzinfo is None:
|
||||||
parsed = parsed.replace(tzinfo=timezone.utc)
|
parsed = parsed.replace(tzinfo=timezone.utc)
|
||||||
return parsed.timestamp()
|
return parsed.timestamp()
|
||||||
|
|
||||||
|
|
||||||
def _now() -> float:
|
|
||||||
return time.monotonic()
|
|
||||||
Reference in new issue
Block a user