Skip to content

Commit 556780c

Browse files
committed
fix: early return for empty segments
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent a493e12 commit 556780c

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

backend/src/database/repositories/memberRepository.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ class MemberRepository {
291291
await new SegmentRepository(options).getSegmentSubprojects(currentSegments)
292292
).map((s) => s.id)
293293

294+
if (segmentIds.length === 0) {
295+
return args.countOnly
296+
? { count: 0 }
297+
: { rows: [], count: 0, limit: args.limit, offset: args.offset }
298+
}
299+
294300
let similarityFilter = ''
295301
const similarityConditions = []
296302

backend/src/database/repositories/segmentRepository.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ class SegmentRepository extends RepositoryBase<
296296
}
297297

298298
async getSegmentSubprojects(segments: string[]) {
299+
if (segments.length === 0) return []
300+
299301
const transaction = this.transaction
300302

301303
const records = await this.options.database.sequelize.query(

0 commit comments

Comments
 (0)