fix: add activity store and user activity caching

This commit is contained in:
pa
2026-03-20 04:40:25 +09:00
parent fbfaf7b93c
commit 15fc0bdf1b
14 changed files with 1084 additions and 101 deletions

View File

@@ -1386,6 +1386,23 @@ const gameLog = {
return data;
},
/**
* Get current user's online sessions after a given timestamp (incremental).
* @param {string} afterCreatedAt - Only return rows created after this timestamp
* @returns {Promise<Array<{created_at: string, time: number}>>}
*/
async getCurrentUserOnlineSessionsAfter(afterCreatedAt) {
const data = [];
await sqliteService.execute(
(dbRow) => {
data.push({ created_at: dbRow[0], time: dbRow[1] || 0 });
},
`SELECT created_at, time FROM gamelog_location WHERE created_at > @after ORDER BY created_at`,
{ '@after': afterCreatedAt }
);
return data;
},
/**
* Get current user's top visited worlds from gamelog_location.
* Groups by world_id and aggregates visit count and total time.