Skip to content

Commit

Permalink
Get all currently active offers endpoint only returns non-pending off…
Browse files Browse the repository at this point in the history
…ers.

Co-authored-by: Francisco Cardoso <[email protected]>
  • Loading branch information
dsantosferreira and FranciscoCardoso913 committed Jun 21, 2023
1 parent 0d10252 commit dabb53b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/models/Offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ OfferSchema.query.current = function() {
return this.where(this.model.filterCurrent());
};

OfferSchema.query.notPending= function(){
return this.where({ isPending: false });
}

/**
* Currently active and non-hidden Offers
*/
Expand Down
2 changes: 1 addition & 1 deletion src/services/company.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class CompanyService {

async releaseOffers(companyId) {
try {
await Offer.updateMany({ company : companyId }, { $set: { "isPending" : false } });
await Offer.updateMany({ owner : companyId }, { $set: { "isPending" : false } });
} catch (err) {
console.error(err);
throw err;
Expand Down
3 changes: 2 additions & 1 deletion src/services/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class OfferService {
} = this.decodeQueryToken(queryToken);

[queryValue, queryFilters] = [searchInfo.value, searchInfo.filters];

offers = this._buildSearchContinuationQuery(lastOfferId, lastOfferScore, queryValue,
showHidden, showAdminReason, queryFilters);
} else {
Expand Down Expand Up @@ -346,6 +346,7 @@ class OfferService {

selectSearchOffers(offers, showHidden, showAdminReason) {
offers.current();
offers.notPending();
if (!showHidden) offers.withoutHidden();
if (!showAdminReason) offers.select("-adminReason");

Expand Down

0 comments on commit dabb53b

Please sign in to comment.