mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 07:07:21 +00:00
fix: add space filter to "join" operation instead of "and" operation (#405)
This commit is contained in:
@ -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 } =
|
||||
|
Reference in New Issue
Block a user