fix: add space filter to "join" operation instead of "and" operation (#405)

This commit is contained in:
ZaydSkaff
2025-06-11 16:28:33 +03:00
committed by GitHub
parent 8503ee728d
commit ea9a65178d

View File

@ -105,18 +105,19 @@ export class CommunityService {
*/
pageable.where = {};
let qb: undefined | SelectQueryBuilder<CommunityEntity> = 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 } =