mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +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:
@@ -840,7 +840,7 @@ api.moveTask = {
|
||||
// Cannot send $pull and $push on same field in one single op
|
||||
const pullQuery = { $pull: {} };
|
||||
pullQuery.$pull[`tasksOrder.${task.type}s`] = task.id;
|
||||
await owner.update(pullQuery).exec();
|
||||
await owner.updateOne(pullQuery).exec();
|
||||
|
||||
let position = to;
|
||||
if (to === -1) position = order.length - 1; // push to bottom
|
||||
@@ -850,7 +850,7 @@ api.moveTask = {
|
||||
$each: [task._id],
|
||||
$position: position,
|
||||
};
|
||||
await owner.update(updateQuery).exec();
|
||||
await owner.updateOne(updateQuery).exec();
|
||||
|
||||
// Update the user version field manually,
|
||||
// it cannot be updated in the pre update hook
|
||||
@@ -1434,7 +1434,7 @@ api.deleteTask = {
|
||||
|
||||
const pullQuery = { $pull: {} };
|
||||
pullQuery.$pull[`tasksOrder.${task.type}s`] = task._id;
|
||||
const taskOrderUpdate = (challenge || user).update(pullQuery).exec();
|
||||
const taskOrderUpdate = (challenge || user).updateOne(pullQuery).exec();
|
||||
|
||||
// Update the user version field manually,
|
||||
// it cannot be updated in the pre update hook
|
||||
|
||||
Reference in New Issue
Block a user