Skip to content

Commit

Permalink
Merge pull request #665 from ita-social-projects/bugfix/664/fix-numbe…
Browse files Browse the repository at this point in the history
…r-of-offers

Fixed active offers number
  • Loading branch information
OlyaKorchan authored Dec 19, 2023
2 parents 1888eff + 4852ebc commit 24146b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit 24146b4

Please sign in to comment.