Skip to content

Commit d8e87e3

Browse files
committed
fix: resolve pr review comments
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent 23ea90d commit d8e87e3

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

backend/src/services/activityService.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import SequelizeRepository from '@/database/repositories/sequelizeRepository'
1010
import { getDataSinkWorkerEmitter } from '@/serverless/utils/queueService'
1111

1212
import ActivityRepository from '../database/repositories/activityRepository'
13-
import SegmentRepository from '../database/repositories/segmentRepository'
1413
import {
1514
UsernameIdentities,
1615
mapUsernameToIdentities,
@@ -122,9 +121,9 @@ export default class ActivityService extends LoggerBase {
122121
const qx = SequelizeRepository.getQueryExecutor(this.options)
123122
const currentSegments = SequelizeRepository.getSegmentIds(this.options)
124123

125-
const subprojectIds = await getSegmentSubprojectIds(qx, currentSegments)
124+
const subprojects = await getSegmentSubprojects(qx, currentSegments)
126125

127-
if (subprojectIds.length === 0) {
126+
if (subprojects.length === 0) {
128127
return {
129128
count: 0,
130129
rows: [],
@@ -133,11 +132,11 @@ export default class ActivityService extends LoggerBase {
133132
}
134133
}
135134

136-
const activitiyTypes = SegmentRepository.getActivityTypes(this.options)
135+
const activitiyTypes = SegmentService.getTenantActivityTypes(subprojects)
137136

138137
const page = await queryActivities(
139138
{
140-
segmentIds: subprojectIds,
139+
segmentIds: subprojects.map((s) => s.id),
141140
filter,
142141
orderBy,
143142
limit,

backend/src/services/segmentService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,12 @@ export default class SegmentService extends LoggerBase {
555555
}
556556

557557
static getTenantActivityTypes(
558-
subprojects: Array<SegmentData | SegmentRawData>,
558+
subprojects?: Array<SegmentData | SegmentRawData> | null,
559559
): ActivityTypeSettings {
560+
if (!subprojects?.length) {
561+
return { custom: {}, default: {} }
562+
}
563+
560564
return subprojects.reduce(
561565
(acc: ActivityTypeSettings, subproject) => {
562566
const activityTypes = buildSegmentActivityTypes(subproject as SegmentRawData)

services/libs/data-access-layer/src/segments/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export async function getSegmentSubprojects(
193193
"grandparentSlug"
194194
from input_segment
195195
)
196-
select s.*
196+
select distinct s.*
197197
from segments s
198198
join segment_level sl on (sl.level = 'child' and s.id = sl.id)
199199
or (sl.level = 'parent' and s."parentSlug" = sl.slug and s."grandparentSlug" = sl."parentSlug")

0 commit comments

Comments
 (0)