mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
chore(migration): set up for Naming Day 2024
This commit is contained in:
committed by
Phillip Thelen
parent
f137c472da
commit
6a9d5a826c
@@ -1,12 +1,12 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
const MIGRATION_NAME = '20240731_naming_day';
|
||||||
import { model as User } from '../../website/server/models/user';
|
import { model as User } from '../../website/server/models/user';
|
||||||
|
|
||||||
const MIGRATION_NAME = '20240731_naming_day';
|
|
||||||
const progressCount = 1000;
|
const progressCount = 1000;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
async function updateUser (user) {
|
async function updateUser (user) {
|
||||||
count += 1;
|
count++;
|
||||||
|
|
||||||
let set;
|
let set;
|
||||||
let push;
|
let push;
|
||||||
@@ -113,14 +113,14 @@ async function updateUser (user) {
|
|||||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||||
|
|
||||||
if (push) {
|
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 () {
|
export default async function processUsers () {
|
||||||
const query = {
|
let query = {
|
||||||
migration: { $ne: MIGRATION_NAME },
|
migration: { $ne: MIGRATION_NAME },
|
||||||
'auth.timestamps.loggedin': { $gt: new Date('2024-07-01') },
|
'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
|
await Promise.all(users.map(updateUser)); // eslint-disable-line no-await-in-loop
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user