From b5d1e9176bce172b773cdfbf6f76dfce7373d033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 18 Aug 2023 20:34:22 -0400 Subject: [PATCH] fix: one more upgrade script fix --- src/upgrades/3.3.0/chat_room_refactor.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/upgrades/3.3.0/chat_room_refactor.js b/src/upgrades/3.3.0/chat_room_refactor.js index 97fe6d6287..9b4f6a4096 100644 --- a/src/upgrades/3.3.0/chat_room_refactor.js +++ b/src/upgrades/3.3.0/chat_room_refactor.js @@ -20,10 +20,14 @@ module.exports = { // calculate user count and set progress.total await batch.processArray(allRoomIds, async (roomIds) => { - await Promise.all(roomIds.map(async (roomId) => { - const userCount = await db.sortedSetCard(`chat:room:${roomId}:uids`); - await db.setObjectField(`chat:room:${roomId}`, 'userCount', userCount); - progress.total += userCount; + const arrayOfRoomData = await db.getObjects(roomIds.map(roomId => `chat:room:${roomId}`)); + await Promise.all(roomIds.map(async (roomId, idx) => { + const roomData = arrayOfRoomData[idx]; + if (roomData) { + const userCount = await db.sortedSetCard(`chat:room:${roomId}:uids`); + await db.setObjectField(`chat:room:${roomId}`, 'userCount', userCount); + progress.total += userCount; + } })); }, { batch: 500,