Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/user/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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}`);
Expand Down