Skip to content

Commit

Permalink
Added filters for system API and Factions API
Browse files Browse the repository at this point in the history
  • Loading branch information
SayakMukhopadhyay committed Sep 13, 2020
1 parent 9543dc1 commit 09abdf4
Show file tree
Hide file tree
Showing 2 changed files with 250 additions and 71 deletions.
34 changes: 34 additions & 0 deletions server/routes/elite_bgs_api/v5/factions.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ let aggregateOptions = {
* description: Name of the recovering state of the faction.
* in: query
* type: string
* - name: influenceGT
* description: Factions with influence greater than. Must be between 0 and 1.
* in: query
* type: string
* - name: influenceLT
* description: Factions with influence lesser than. Must be between 0 and 1.
* in: query
* type: string
* - name: minimal
* description: Get minimal data of the faction.
* in: query
Expand Down Expand Up @@ -187,6 +195,32 @@ router.get('/', cors(), async (req, res, next) => {
}
};
}
if (req.query.influenceGT && req.query.influenceGT) {
query["faction_presence"] = {
$elemMatch: {
influence: {
$gt: +request.query.influenceGT,
$lt: +request.query.influenceLT
}
}
};
} else if (req.query.influenceGT) {
query["faction_presence"] = {
$elemMatch: {
influence: {
$gt: +request.query.influenceGT
}
}
};
} else if (req.query.influenceLT) {
query["faction_presence"] = {
$elemMatch: {
influence: {
$gt: +request.query.influenceLT,
}
}
};
}
if (req.query.minimal === 'true') {
minimal = true;
}
Expand Down
Loading

0 comments on commit 09abdf4

Please sign in to comment.