Skip to content

Commit

Permalink
ADM-791:[backend]refactor: should get source control report and the p…
Browse files Browse the repository at this point in the history
…ipeline report
  • Loading branch information
Dnjoa committed Feb 4, 2024
1 parent 0205d81 commit 591e916
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,16 @@ public void generateBoardReport(GenerateReportRequest request) {
public void generateDoraReport(GenerateReportRequest request) {
removePreviousAsyncException(request.getPipelineReportId());
removePreviousAsyncException(request.getSourceControlReportId());
FetchedData fetchedData = fetchOriginalData(request, new FetchedData());
if (CollectionUtils.isNotEmpty(request.getPipelineMetrics())) {
generatePipelineReport(request.toPipelineRequest(), fetchedData);
}
FetchedData fetchedData = new FetchedData();
if (CollectionUtils.isNotEmpty(request.getSourceControlMetrics())) {
generateSourceControlReport(request.toSourceControlRequest(), fetchedData);
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);
}
generateCSVForPipeline(request, fetchedData.getBuildKiteData());
asyncMetricsDataHandler.updateMetricsDataCompletedInHandler(request.getCsvTimeStamp(), DORA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import heartbeat.controller.report.dto.request.CodebaseSetting;
import heartbeat.controller.report.dto.request.GenerateReportRequest;
import heartbeat.controller.report.dto.request.JiraBoardSetting;
import heartbeat.controller.report.dto.request.MetricEnum;
import heartbeat.controller.report.dto.request.MetricType;
import heartbeat.controller.report.dto.response.ChangeFailureRate;
import heartbeat.controller.report.dto.response.Classification;
Expand Down Expand Up @@ -555,7 +556,8 @@ void shouldGenerateCsvWithCachedDataWhenBuildKiteDataAlreadyExisted() {
.considerHoliday(false)
.startTime("10000")
.endTime("20000")
.metrics(List.of("lead time for changes", "change failure rate"))
.metrics(
List.of(MetricEnum.LEAD_TIME_FOR_CHANGES.getValue(), MetricEnum.CHANGE_FAILURE_RATE.getValue()))
.codebaseSetting(CodebaseSetting.builder().build())
.buildKiteSetting(BuildKiteSetting.builder().build())
.csvTimeStamp(TIMESTAMP)
Expand All @@ -567,9 +569,9 @@ void shouldGenerateCsvWithCachedDataWhenBuildKiteDataAlreadyExisted() {
List<PipelineCSVInfo> pipelineCSVInfos = List.of();
when(pipelineService.generateCSVForPipelineWithCodebase(any(), any(), any(), any(), any()))
.thenReturn(pipelineCSVInfos);
when(pipelineService.fetchGithubData(request))
when(pipelineService.fetchGithubData(any()))
.thenReturn(FetchedData.BuildKiteData.builder().buildInfosList(List.of()).build());
when(pipelineService.fetchBuildKiteInfo(request))
when(pipelineService.fetchBuildKiteInfo(any()))
.thenReturn(FetchedData.BuildKiteData.builder().buildInfosList(List.of()).build());
LeadTimeForChanges fakeLeadTimeForChange = LeadTimeForChanges.builder().build();
when(leadTimeForChangesCalculator.calculate(any())).thenReturn(fakeLeadTimeForChange);
Expand All @@ -591,7 +593,7 @@ void shouldUpdateMetricCompletedWhenGenerateCsvWithSourceControlReportFailed() {
.considerHoliday(false)
.startTime("10000")
.endTime("20000")
.metrics(List.of("lead time for changes"))
.metrics(List.of(MetricEnum.LEAD_TIME_FOR_CHANGES.getValue()))
.codebaseSetting(CodebaseSetting.builder().build())
.buildKiteSetting(BuildKiteSetting.builder().build())
.csvTimeStamp(TIMESTAMP)
Expand Down

0 comments on commit 591e916

Please sign in to comment.