diff --git a/src/community/services/community.service.ts b/src/community/services/community.service.ts index 081c0ac..fc33011 100644 --- a/src/community/services/community.service.ts +++ b/src/community/services/community.service.ts @@ -105,18 +105,19 @@ export class CommunityService { */ pageable.where = {}; let qb: undefined | SelectQueryBuilder = undefined; + + qb = this.communityRepository + .createQueryBuilder('c') + .leftJoin('c.spaces', 's', 's.disabled = false') + .where('c.project = :projectUuid', { projectUuid }) + .andWhere(`c.name != '${ORPHAN_COMMUNITY_NAME}-${project.name}'`) + .distinct(true); if (pageable.search) { - qb = this.communityRepository - .createQueryBuilder('c') - .leftJoin('c.spaces', 's') - .where('c.project = :projectUuid', { projectUuid }) - .andWhere(`c.name != '${ORPHAN_COMMUNITY_NAME}-${project.name}'`) - .andWhere('s.disabled = false') - .andWhere( - `c.name ILIKE '%${pageable.search}%' OR s.space_name ILIKE '%${pageable.search}%'`, - ) - .distinct(true); + qb.andWhere( + `c.name ILIKE '%${pageable.search}%' OR s.space_name ILIKE '%${pageable.search}%'`, + ); } + const customModel = TypeORMCustomModel(this.communityRepository); const { baseResponseDto, paginationResponseDto } =