Skip to content

Commit

Permalink
Extracted repeated code to selectSearchOffers() method
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoRosendo committed May 24, 2022
1 parent a2751ae commit f445589
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/services/offer.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,7 @@ class OfferService {

) : Offer.find(this._buildFilterQuery(filters)));

offers.current();
if (!showHidden) offers.withoutHidden();
if (!showAdminReason) offers.select("-adminReason");

return offers;
return this.selectSearchOffers(offers, showHidden, showAdminReason);
}

/**
Expand Down Expand Up @@ -290,9 +286,7 @@ class OfferService {
{ _id: { "$gt": ObjectId(lastOfferId) } }
] });

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

return offers;
Expand Down Expand Up @@ -345,6 +339,14 @@ class OfferService {
return constraints.length ? { "$and": constraints } : {};
}

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

return offers;
}

/**
* Encodes a query token, by taking the an id and FTS score if present, and encoding them in safe url base64
* @param {*} id
Expand Down

0 comments on commit f445589

Please sign in to comment.