From 4852ebc61b15bb30340b5681cee3d44a942f576e Mon Sep 17 00:00:00 2001 From: Olia Slisarchuk Date: Mon, 4 Dec 2023 19:39:36 +0200 Subject: [PATCH] fixed active offers number --- models/offer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/offer.js b/models/offer.js index d0cac0b0..8c5281d3 100644 --- a/models/offer.js +++ b/models/offer.js @@ -121,9 +121,9 @@ const offerSchema = new Schema( ) offerSchema.statics.calcTotalOffers = async function (category, subject, authorRole) { - const categoryTotalOffersQty = await this.countDocuments({ category, authorRole }) + const categoryTotalOffersQty = await this.countDocuments({ category, authorRole, status : OFFER_STATUS_ENUM[0] }) await Category.findByIdAndUpdate(category, { $set: { [`totalOffers.${authorRole}`]: categoryTotalOffersQty } }).exec() - const subjectTotalOffersQty = await this.countDocuments({ subject, authorRole }) + const subjectTotalOffersQty = await this.countDocuments({ subject, authorRole, status: OFFER_STATUS_ENUM[0] }) await Subject.findByIdAndUpdate(subject, { $set: { [`totalOffers.${authorRole}`]: subjectTotalOffersQty } }).exec() }