improve avatar time spent loading performance by fetching all times in one query

This commit is contained in:
pa
2026-03-23 11:40:41 +09:00
parent 369f5130b5
commit 1895d0f25c
2 changed files with 23 additions and 11 deletions
+12
View File
@@ -53,6 +53,18 @@ const avatarFavorites = {
return ref;
},
async getAllAvatarTimeSpent() {
const map = new Map();
await sqliteService.execute(
(row) => {
map.set(row[0], row[1] || 0);
},
`SELECT avatar_id, time FROM ${dbVars.userPrefix}_avatar_history`
);
return map;
},
addAvatarTimeSpent(avatarId, timeSpent) {
sqliteService.executeNonQuery(
`UPDATE ${dbVars.userPrefix}_avatar_history SET time = time + @timeSpent WHERE avatar_id = @avatarId`,