Skip to content

Commit

Permalink
fix(api): Support filters in structures from a geographical category
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Jan 9, 2024
1 parent 88d2256 commit 6c4d036
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/api/geographicalcategories/root/root.middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,18 @@ export async function getGeographicalCategoryById(req, res, next) {
export async function getStructureFromGeoCategory(req, res, next) {
try {
const { geographicalCategory } = req;

const { limit, skip } = req.query;

const filters = {
const { filters, limit, skip } = req.query;
const filtersTmp = {
...filters,
'localisations.geometry': {
$geoWithin: {
$geometry: geographicalCategory.geometry,
},
},
'localisations.active': true,
'localisations.active': { $ne: false },
};

filters['localisations.active'] = { $ne: false };

const { data } = await structuresRepository.find({ filters, useQuery: readQuery, limit, skip });
const { data } = await structuresRepository.find({ filters: filtersTmp, useQuery: readQuery, limit, skip });
res.status(200).json({ data, totalCount: data.length });
next();
} catch (error) {
Expand Down

0 comments on commit 6c4d036

Please sign in to comment.