Skip to content

Commit

Permalink
Merge pull request #378 from marchhq/dev
Browse files Browse the repository at this point in the history
fix: overdue
  • Loading branch information
sajdakabir authored Oct 23, 2024
2 parents 20df265 + 749f3fd commit a3ad8d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions apps/backend/src/models/lib/item.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ ItemSchema.pre("save", function (next) {
next();
});

ItemSchema.pre("findOneAndUpdate", function (next) {
const update = this.getUpdate();
if (update.$set && update.$set.status === "done") {
update.$set.isCompleted = true;
} else if (update.$set && update.$set.status) {
update.$set.isCompleted = false;
}

next();
});

const Item = db.model("Item", ItemSchema, "items");

export {
Expand Down
5 changes: 3 additions & 2 deletions apps/backend/src/services/lib/item.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ const getOverdueItemsByDate = async (me, date) => {
const items = await Item.find({
user: me,
dueDate: { $lt: date },
isArchived: false,
isDeleted: false
isCompleted: false,
isDeleted: false,
isArchived: false
})
.sort({ createdAt: -1 });

Expand Down

0 comments on commit a3ad8d4

Please sign in to comment.