File tree Expand file tree Collapse file tree
services/libs/data-access-layer/src/segments Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import SequelizeRepository from '@/database/repositories/sequelizeRepository'
1010import { getDataSinkWorkerEmitter } from '@/serverless/utils/queueService'
1111
1212import ActivityRepository from '../database/repositories/activityRepository'
13- import SegmentRepository from '../database/repositories/segmentRepository'
1413import {
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,
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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")
You can’t perform that action at this time.
0 commit comments