From 43060f3cde45aa98d426cc0311efc958ba23e537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 12 Jul 2023 19:54:46 -0400 Subject: [PATCH] perf: faster upgrade script --- src/upgrades/3.3.0/chat_room_refactor.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/upgrades/3.3.0/chat_room_refactor.js b/src/upgrades/3.3.0/chat_room_refactor.js index 9b3337fc3c..7c008a9764 100644 --- a/src/upgrades/3.3.0/chat_room_refactor.js +++ b/src/upgrades/3.3.0/chat_room_refactor.js @@ -21,12 +21,14 @@ module.exports = { progress.total = allRoomIds.length; await batch.processArray(allRoomIds, async (roomIds) => { progress.incr(roomIds.length); - await Promise.all(roomIds.map(async (roomId) => { - const [uids, roomData] = await Promise.all([ - db.getSortedSetRange(`chat:room:${roomId}:uids`, 0, -1), - db.getObject(`chat:room:${roomId}`), - ]); + const [arrayOfUids, arrayOfRoomData] = await Promise.all([ + db.getSortedSetsMembers(roomIds.map(roomId => `chat:room:${roomId}:uids`)), + db.getObjects(roomIds.map(roomId => `chat:room:${roomId}`)), + ]); + await Promise.all(roomIds.map(async (roomId, index) => { + const uids = arrayOfUids[index]; + const roomData = arrayOfRoomData[index]; if (!uids.length && !roomData) { return; }