Stabilize visitor panel ordering

This commit is contained in:
rajchales-monito
2026-07-30 13:43:28 +02:00
parent 4afc88559f
commit 349f42346e
2 changed files with 41 additions and 5 deletions
+3 -2
View File
@@ -1825,8 +1825,8 @@ function currentVisitors() {
FROM visitor_sessions vs
JOIN sites s ON s.id = vs.site_id
LEFT JOIN visitor_profiles vp ON vp.site_id = vs.site_id AND vp.visitor_token = vs.visitor_token
WHERE datetime(vs.last_seen_at) >= datetime('now', '-${presence.offlineSeconds} seconds')
ORDER BY datetime(vs.last_seen_at) DESC
WHERE datetime(COALESCE(vs.last_activity_at, vs.last_seen_at)) >= datetime('now', '-${presence.offlineSeconds} seconds')
ORDER BY datetime(vs.first_seen_at) ASC, vs.id ASC
LIMIT 100
`).all();
return rows.map((row) => formatVisitorSession(row, presence));
@@ -1861,6 +1861,7 @@ function formatVisitorSession(row, thresholds = adminPresenceSettings()) {
countryCode,
countryFlag: countryCode ? flagEmoji(countryCode) : "",
sessionSeconds: sessionSeconds(row.browsing_history_json, row.first_seen_at),
firstSeenAt: row.first_seen_at,
lastActivityAt: row.last_activity_at,
lastSeenAt: row.last_seen_at
};