chore(migration): set up for Naming Day 2024

This commit is contained in:
Sabe Jones
2024-07-30 15:12:56 -05:00
committed by Phillip Thelen
parent f137c472da
commit 6a9d5a826c

View File

@@ -1,12 +1,12 @@
/* eslint-disable no-console */
const MIGRATION_NAME = '20240731_naming_day';
import { model as User } from '../../website/server/models/user';
const MIGRATION_NAME = '20240731_naming_day';
const progressCount = 1000;
let count = 0;
async function updateUser (user) {
count += 1;
count++;
let set;
let push;
@@ -113,14 +113,14 @@ async function updateUser (user) {
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
if (push) {
return user.updateOne({ $set: set, $inc: inc, $push: push }).exec();
return await user.updateOne({ $set: set, $inc: inc, $push: push }).exec();
} else {
return await user.updateOne({ $set: set, $inc: inc }).exec();
}
return user.updateOne({ $set: set, $inc: inc }).exec();
}
export default async function processUsers () {
const query = {
let query = {
migration: { $ne: MIGRATION_NAME },
'auth.timestamps.loggedin': { $gt: new Date('2024-07-01') },
};
@@ -150,4 +150,4 @@ export default async function processUsers () {
await Promise.all(users.map(updateUser)); // eslint-disable-line no-await-in-loop
}
}
};