remove space join if not required

This commit is contained in:
Mhd Zayd Skaff
2025-07-24 10:01:42 +03:00
parent beed6fcfb7
commit 7ae826eb71

View File

@ -187,12 +187,14 @@ export class CommunityService {
const matchingCommunityIdsQb = this.communityRepository
.createQueryBuilder('c')
.select('c.uuid')
.leftJoin('c.spaces', 'space')
.where('c.project = :projectUuid', { projectUuid })
.andWhere('c.name != :orphanCommunityName', {
orphanCommunityName: `${ORPHAN_COMMUNITY_NAME}-${project.name}`,
})
.distinct(true);
if (includeSpaces) {
matchingCommunityIdsQb.leftJoin('c.spaces', 'space');
}
if (search) {
matchingCommunityIdsQb