diff --git a/src/user/delete.js b/src/user/delete.js index 8f99117c59..51ce498fde 100644 --- a/src/user/delete.js +++ b/src/user/delete.js @@ -15,6 +15,21 @@ const messaging = require('../messaging'); const plugins = require('../plugins'); const batch = require('../batch'); +async function updateCount(uids, name, fieldName) { + console.log('Talal: Starting updateCount function'); + await batch.processArray(uids, async (uids) => { + const counts = await db.sortedSetsCard(uids.map(uid => name + uid)); + const bulkSet = counts.map( + (count, index) => ([`user:${uids[index]}`, { [fieldName]: count || 0 }]) + ); + await db.setObjectBulk(bulkSet); + }, { + batch: 500, + }); + console.log('Talal: Finished updateCount function'); +} + + module.exports = function (User) { const deletesInProgress = {}; @@ -208,17 +223,6 @@ module.exports = function (User) { db.getSortedSetRange(`following:${uid}`, 0, -1), ]); - async function updateCount(uids, name, fieldName) { - await batch.processArray(uids, async (uids) => { - const counts = await db.sortedSetsCard(uids.map(uid => name + uid)); - const bulkSet = counts.map( - (count, index) => ([`user:${uids[index]}`, { [fieldName]: count || 0 }]) - ); - await db.setObjectBulk(bulkSet); - }, { - batch: 500, - }); - } const followingSets = followers.map(uid => `following:${uid}`); const followerSets = following.map(uid => `followers:${uid}`);