diff --git a/src/domain-services/flows/flow-search-service.ts b/src/domain-services/flows/flow-search-service.ts index 896128b5..e6e82168 100644 --- a/src/domain-services/flows/flow-search-service.ts +++ b/src/domain-services/flows/flow-search-service.ts @@ -153,6 +153,12 @@ export class FlowSearchService { const externalReferences = externalReferencesMap.get(flow.id) ?? []; const reportDetails = reportDetailsMap.get(flow.id) ?? []; + const reportDetailsWithChannel = + this.reportDetailService.addChannelToReportDetails( + reportDetails, + categories + ); + let parkedParentSource: FlowParkedParentSource[] = []; if (flow.activeStatus && flowLink.length > 0) { parkedParentSource = await this.getParketParents( @@ -188,7 +194,7 @@ export class FlowSearchService { childIDs, parentIDs, externalReferences, - reportDetails, + reportDetailsWithChannel, parkedParentSource ); }) diff --git a/src/domain-services/report-details/graphql/types.ts b/src/domain-services/report-details/graphql/types.ts index 3d4ddfa9..175f3c73 100644 --- a/src/domain-services/report-details/graphql/types.ts +++ b/src/domain-services/report-details/graphql/types.ts @@ -32,4 +32,7 @@ export class ReportDetail extends BaseType { @Field(() => Number, { nullable: true }) organizationID: number | null; + + @Field(() => String, { nullable: true }) + channel: string | null; } diff --git a/src/domain-services/report-details/report-detail-service.ts b/src/domain-services/report-details/report-detail-service.ts index b7ef5533..9d1fb85b 100644 --- a/src/domain-services/report-details/report-detail-service.ts +++ b/src/domain-services/report-details/report-detail-service.ts @@ -3,6 +3,7 @@ import { type FlowId } from '@unocha/hpc-api-core/src/db/models/flow'; import { Op } from '@unocha/hpc-api-core/src/db/util/conditions'; import { type InstanceDataOfModel } from '@unocha/hpc-api-core/src/db/util/raw-model'; import { Service } from 'typedi'; +import { type Category } from '../categories/graphql/types'; import { type ReportDetail } from './graphql/types'; @Service() export class ReportDetailService { @@ -65,6 +66,21 @@ export class ReportDetailService { createdAt: reportDetail.createdAt.toISOString(), updatedAt: reportDetail.updatedAt.toISOString(), organizationID: reportDetail.organizationID, + channel: null, }; } + + addChannelToReportDetails( + reportDetails: ReportDetail[], + categories: Category[] + ) { + for (const reportDetail of reportDetails) { + const category = categories.find((cat) => cat.group === 'reportChannel'); + + if (category) { + reportDetail.channel = category.name; + } + } + return reportDetails; + } }