mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Database Access optimisations (#14544)
* Optimize database access during spell casting * load less data when casting spells * Begin migrating update calls to updateOne and updateMany * Only update user objects that don’t have notification yet * fix test * fix spy * Don’t unnecessarily update user when requesting invalid guild * fix sort order for middlewares to not load user twice every request * fix tests * fix integration test * fix skill usage not always deducting mp * addtest case for blessing spell * fix healAll * fix lint * Fix error for when some spells are used outside of party * Add check to not run bulk spells in web client * fix(tags): change const to let --------- Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
@@ -225,10 +225,9 @@ schema.statics.pushNotification = async function pushNotification (
|
||||
throw validationResult;
|
||||
}
|
||||
|
||||
await this.update(
|
||||
await this.updateMany(
|
||||
query,
|
||||
{ $push: { notifications: newNotification.toObject() } },
|
||||
{ multi: true },
|
||||
).exec();
|
||||
};
|
||||
|
||||
@@ -274,13 +273,12 @@ schema.statics.addAchievementUpdate = async function addAchievementUpdate (query
|
||||
const validationResult = newNotification.validateSync();
|
||||
if (validationResult) throw validationResult;
|
||||
|
||||
await this.update(
|
||||
await this.updateMany(
|
||||
query,
|
||||
{
|
||||
$push: { notifications: newNotification.toObject() },
|
||||
$set: { [`achievements.${achievement}`]: true },
|
||||
},
|
||||
{ multi: true },
|
||||
).exec();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user