Skip to content

Commit

Permalink
hotfix: bug search bal
Browse files Browse the repository at this point in the history
  • Loading branch information
fufeck committed Sep 11, 2024
1 parent 925ddfb commit 1ad2fb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions apps/api/src/modules/base_locale/base_locale.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ export class BaseLocaleService {
limit?: number,
offset?: number,
): Promise<BaseLocale[]> {
return this.basesLocalesRepository
const query = this.basesLocalesRepository
.createQueryBuilder()
.select()
.where(where)
.andWhere('lower(emails::text)::text[] @> ARRAY[:email]', { email })
.limit(limit)
.offset(offset)
.getMany();
.offset(offset);

if (email) {
query.andWhere('lower(emails::text)::text[] @> ARRAY[:email]', { email });
}
return query.getMany();
}

public async countGroupByStatus(): Promise<any[]> {
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/modules/base_locale/pipe/search_query.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
HttpException,
HttpStatus,
} from '@nestjs/common';
import { FindOptionsWhere, Not } from 'typeorm';
import { FindOptionsWhere, IsNull, Not } from 'typeorm';

import {
BaseLocale,
Expand Down Expand Up @@ -46,9 +46,9 @@ export class SearchQueryPipe implements PipeTransform {
}

if (query.deleted === 'false') {
res.filters.deletedAt = null;
res.filters.deletedAt = IsNull();
} else if (query.deleted === 'true') {
res.filters.deletedAt = Not(null);
res.filters.deletedAt = Not(IsNull());
} else if (query.deleted) {
throw new HttpException(
'La valeur du champ "deleted" est invalide',
Expand Down

0 comments on commit 1ad2fb5

Please sign in to comment.