You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
738 B
JavaScript
28 lines
738 B
JavaScript
'use strict';
|
|
|
|
const db = require('../../database');
|
|
const batch = require('../../batch');
|
|
|
|
module.exports = {
|
|
name: 'Clean flag byCid zsets',
|
|
timestamp: Date.UTC(2019, 8, 24),
|
|
method: async function () {
|
|
const { progress } = this;
|
|
|
|
await batch.processSortedSet('flags:datetime', async (flagIds) => {
|
|
progress.incr(flagIds.length);
|
|
const flagData = await db.getObjects(flagIds.map(id => `flag:${id}`));
|
|
const bulkRemove = [];
|
|
for (const flagObj of flagData) {
|
|
if (flagObj && flagObj.type === 'user' && flagObj.targetId && flagObj.flagId) {
|
|
bulkRemove.push([`flags:byCid:${flagObj.targetId}`, flagObj.flagId]);
|
|
}
|
|
}
|
|
|
|
await db.sortedSetRemoveBulk(bulkRemove);
|
|
}, {
|
|
progress: progress,
|
|
});
|
|
},
|
|
};
|