Skip to content

Commit

Permalink
fix(datatrakWeb): Fix report survey filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
alexd-bes committed Sep 20, 2024
1 parent 4a737f4 commit abfda67
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/datatrak-web-server/src/routes/SurveysRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ export class SurveysRoute extends Route<SurveysRequest> {
const { fields = [], projectId, countryCode } = query;
const country = await models.country.findOne({ code: countryCode });

const surveys = await ctx.services.central.fetchResources(`countries/${country.id}/surveys`, {
const queryUrl = countryCode ? `countries/${country.id}/surveys` : 'surveys';

const filter: Record<string, string> = {};

if (projectId) {
filter.project_id = projectId;
}

const surveys = await ctx.services.central.fetchResources(queryUrl, {
...query,
filter: {
project_id: projectId,
},
filter,
columns: fields,
pageSize: 'ALL', // Override default page size of 100
});
Expand Down

0 comments on commit abfda67

Please sign in to comment.