diff --git a/backend/src/database/repositories/segmentRepository.ts b/backend/src/database/repositories/segmentRepository.ts index d5edda0e5b..eff0535d39 100644 --- a/backend/src/database/repositories/segmentRepository.ts +++ b/backend/src/database/repositories/segmentRepository.ts @@ -296,6 +296,10 @@ class SegmentRepository extends RepositoryBase< } async fetchTenantActivityChannels(segmentIds: string[]) { + if (segmentIds.length === 0) { + return {} + } + const transaction = this.transaction const records = await this.options.database.sequelize.query( diff --git a/backend/src/services/activityService.ts b/backend/src/services/activityService.ts index 9ac5708835..38de946a1b 100644 --- a/backend/src/services/activityService.ts +++ b/backend/src/services/activityService.ts @@ -108,6 +108,10 @@ export default class ActivityService extends LoggerBase { const subprojectIds = await getSegmentSubprojectIds(qx, currentSegments) + if (subprojectIds.length === 0) { + return {} + } + return SegmentService.getTenantActivityChannels(subprojectIds, this.options) }