Spaces:
Sleeping
Sleeping
Sasha commited on
Commit ·
d931d22
1
Parent(s): 54a28a5
fix: logRolesBatch always updates roles, only preserves newer last_seen
Browse files832 unmodified lines833834835836837838839840841842832 unmodified lines.in('username', uniqueChatUsers.map(u => u.username));const existingMap = new Map((existingUsers || []).map(u => [u.username, new Date(u.last_seen).getTime()]));const toUpsert = uniqueChatUsers.filter(u => {const oldTime = existingMap.get(u.username) || 0;const newTime = new Date(u.last_seen).getTime();return newTime > oldTime;});if (toUpsert.length > 0) {832 unmodified lines833834835836837838839840841842843844845846847848832 unmodified lines.in('username', uniqueChatUsers.map(u => u.username));const existingMap = new Map((existingUsers || []).map(u => [u.username, new Date(u.last_seen).getTime()]));// Always update roles (is_mod/is_sub/is_vip), but only advance last_seen if newerconst toUpsert = uniqueChatUsers.map(u => {const oldTime = existingMap.get(u.username) || 0;const newTime = new Date(u.last_seen).getTime();return {...u,// Keep last_seen as the newer of the twolast_seen: newTime > oldTime ? u.last_seen : (existingUsers || []).find(e => e.username === u.username)?.last_seen || u.last_seen};});if (toUpsert.length > 0) {
server/db.js+8-2