feat(backend): presence stats count time online from sessions in the browser time zone, capture uptime marks hours without data, presence reaches every stream of the account, message volume keeps empty days
This commit is contained in:
1 parent
bb38e23f29
commit
f44597b2dc
14 files changed
+585
-26
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,16 @@
|
||||
import asyncpg
|
||||
|
||||
_HEARTBEAT = """
|
||||
WITH extended AS (
|
||||
UPDATE capture_uptime SET seen_at = now()
|
||||
WHERE account_id = $1 AND seen_at >= now() - interval '150 seconds'
|
||||
RETURNING account_id
|
||||
)
|
||||
INSERT INTO capture_uptime (account_id, started_at, seen_at)
|
||||
SELECT $1, now(), now()
|
||||
WHERE NOT EXISTS (SELECT 1 FROM extended)
|
||||
"""
|
||||
|
||||
|
||||
async def heartbeat(pool: asyncpg.Pool, account_id: int) -> None:
|
||||
await pool.execute(_HEARTBEAT, account_id)
|
||||
Reference in new issue
Block a user