From f8995d21ee887d8f409ae317e0333c713bf3d25f Mon Sep 17 00:00:00 2001 From: Yunsong Date: Sun, 4 Feb 2024 11:33:31 +0800 Subject: [PATCH] ADM-791:[backend]refactor: should get pipeline report and then source control report --- .../report/GenerateReporterService.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/heartbeat/service/report/GenerateReporterService.java b/backend/src/main/java/heartbeat/service/report/GenerateReporterService.java index 9d9caffbfe..f056579d1f 100644 --- a/backend/src/main/java/heartbeat/service/report/GenerateReporterService.java +++ b/backend/src/main/java/heartbeat/service/report/GenerateReporterService.java @@ -100,16 +100,16 @@ public void generateDoraReport(GenerateReportRequest request) { removePreviousAsyncException(request.getPipelineReportId()); removePreviousAsyncException(request.getSourceControlReportId()); FetchedData fetchedData = new FetchedData(); - if (CollectionUtils.isNotEmpty(request.getSourceControlMetrics())) { - GenerateReportRequest sourceControlRequest = request.toSourceControlRequest(); - fetchOriginalData(sourceControlRequest, fetchedData); - generateSourceControlReport(sourceControlRequest, fetchedData); - } if (CollectionUtils.isNotEmpty(request.getPipelineMetrics())) { GenerateReportRequest pipelineRequest = request.toPipelineRequest(); fetchOriginalData(pipelineRequest, fetchedData); generatePipelineReport(pipelineRequest, fetchedData); } + if (CollectionUtils.isNotEmpty(request.getSourceControlMetrics())) { + GenerateReportRequest sourceControlRequest = request.toSourceControlRequest(); + fetchOriginalData(sourceControlRequest, fetchedData); + generateSourceControlReport(sourceControlRequest, fetchedData); + } generateCSVForPipeline(request, fetchedData.getBuildKiteData()); asyncMetricsDataHandler.updateMetricsDataCompletedInHandler(request.getCsvTimeStamp(), DORA); } @@ -243,13 +243,7 @@ private FetchedData fetchOriginalData(GenerateReportRequest request, FetchedData if (CollectionUtils.isNotEmpty(request.getPipelineMetrics())) { if (request.getBuildKiteSetting() == null) throw new BadRequestException("Failed to fetch BuildKite info due to BuildKite setting is null."); - FetchedData.BuildKiteData buildKiteData = pipelineService.fetchBuildKiteInfo(request); - BuildKiteData cachedBuildKiteData = fetchedData.getBuildKiteData(); - if (cachedBuildKiteData != null) { - List pipelineLeadTimes = cachedBuildKiteData.getPipelineLeadTimes(); - buildKiteData.setPipelineLeadTimes(pipelineLeadTimes); - } - fetchedData.setBuildKiteData(buildKiteData); + fetchedData.setBuildKiteData(pipelineService.fetchBuildKiteInfo(request)); } return fetchedData;