|
|
|
@ -11,10 +11,11 @@ module.exports = {
|
|
|
|
|
method: async function () {
|
|
|
|
|
const { progress } = this;
|
|
|
|
|
|
|
|
|
|
progress.total = await db.sortedSetCard(`chat:rooms`);
|
|
|
|
|
await batch.processSortedSet(`chat:rooms`, async (roomIds) => {
|
|
|
|
|
progress.incr(roomIds.length);
|
|
|
|
|
for (const roomId of roomIds) {
|
|
|
|
|
const allRoomIds = await db.getSortedSetRange(`chat:rooms`, 0, -1);
|
|
|
|
|
|
|
|
|
|
progress.total = allRoomIds.length;
|
|
|
|
|
|
|
|
|
|
for (const roomId of allRoomIds) {
|
|
|
|
|
await batch.processSortedSet(`chat:room:${roomId}:mids`, async (mids) => {
|
|
|
|
|
let messageData = await db.getObjects(mids.map(mid => `message:${mid}`));
|
|
|
|
|
messageData.forEach((m, idx) => {
|
|
|
|
@ -37,10 +38,9 @@ module.exports = {
|
|
|
|
|
}, {
|
|
|
|
|
batch: 500,
|
|
|
|
|
});
|
|
|
|
|
progress.incr(1);
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
batch: 500,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const count = await db.sortedSetCard(`messages:mid`);
|
|
|
|
|
await db.setObjectField('global', 'messageCount', count);
|
|
|
|
|
},
|
|
|
|
|