Skip to content

Commit

Permalink
fix: hide token/email in route /stats/bals
Browse files Browse the repository at this point in the history
  • Loading branch information
fufeck committed Mar 25, 2024
1 parent 2bbd5d8 commit 1530c3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/api/src/modules/stats/stats.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class StatsController {
@Body() codeCommeDto: CodeCommuneDTO,
@Res() res: Response,
) {
const result: BaseLocale[] =
const result: Omit<BaseLocale, 'token' | 'emails'>[] =
await this.statsService.findBalInCodeCommuneWithFields(
fields,
codeCommeDto.codeCommunes,
Expand Down
8 changes: 5 additions & 3 deletions apps/api/src/modules/stats/stats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@ export class StatsService {
public async findBalInCodeCommuneWithFields(
fields: string[] = [],
codeCommunes: string[] = [],
): Promise<BaseLocale[]> {
): Promise<Omit<BaseLocale, 'token' | 'emails'>[]> {
const filters: FilterQuery<BaseLocale> = {
status: { $ne: 'demo' },
_deleted: null,
...(codeCommunes && { commune: { $in: codeCommunes } }),
};
let selector: Record<string, number> = null;
const selector: Record<string, number> = {};
if (fields.length > 0) {
selector = {};
fields.forEach((f) => {
selector[f] = 1;
});
}
selector['token'] = 0;
selector['emails'] = 0;

return this.baseLocaleService.findMany(filters, selector);
}

Expand Down

0 comments on commit 1530c3d

Please sign in to comment.