Skip to content

Commit 2a317e9

Browse files
authored
Merge pull request #160 from PublicisSapient/bugfix/DTS-50705
Fix the use case in which a SCRUM project doesn't have any sprints av…
2 parents 98ff24a + 013db58 commit 2a317e9

File tree

2 files changed

+56
-41
lines changed

2 files changed

+56
-41
lines changed

ai-data-processor/src/main/java/com/publicissapient/kpidashboard/job/kpimaturitycalculation/service/KpiMaturityCalculationService.java

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ public KpiMaturity calculateKpiMaturityForProject(ProjectInputDTO projectInput)
162162
return calculateKpiMaturity(projectInput, kpiElementList);
163163
}
164164

165-
private List<KpiElement> processAllKpiRequests(List<KpiRequest> kpiRequests, ProjectDeliveryMethodology projectDeliveryMethodology) {
166-
if(projectDeliveryMethodology == ProjectDeliveryMethodology.KANBAN) {
165+
private List<KpiElement> processAllKpiRequests(List<KpiRequest> kpiRequests,
166+
ProjectDeliveryMethodology projectDeliveryMethodology) {
167+
if (projectDeliveryMethodology == ProjectDeliveryMethodology.KANBAN) {
167168
return this.knowHOWClient.getKpiIntegrationValuesKanban(kpiRequests);
168169
}
169170
return this.knowHOWClient.getKpiIntegrationValues(kpiRequests);
@@ -326,39 +327,45 @@ private List<KpiRequest> constructKpiRequests(ProjectInputDTO projectInput) {
326327
List<KpiRequest> kpiRequests = new ArrayList<>();
327328

328329
Map<String, List<KpiMaster>> kpisGroupedBySource = this.kpisEligibleForMaturityCalculation.stream()
329-
.filter(kpiMaster -> kpiMaster.getKanban() == (projectInput.deliveryMethodology() == ProjectDeliveryMethodology.KANBAN))
330+
.filter(kpiMaster -> kpiMaster
331+
.getKanban() == (projectInput.deliveryMethodology() == ProjectDeliveryMethodology.KANBAN))
330332
.collect(Collectors.groupingBy(KpiMaster::getKpiSource));
331333

332334
for (Map.Entry<String, List<KpiMaster>> entry : kpisGroupedBySource.entrySet()) {
333335
KpiGranularity kpiGranularity = KpiGranularity.getByKpiXAxisLabel(entry.getValue().get(0).getXAxisLabel());
334336
switch (kpiGranularity) {
335-
case MONTH, WEEK, DAY -> kpiRequests.add(KpiRequest.builder()
336-
.kpiIdList(new ArrayList<>(entry.getValue().stream().map(KpiMaster::getKpiId).toList()))
337-
.selectedMap(Map.of(CommonConstant.HIERARCHY_LEVEL_ID_PROJECT, List.of(projectInput.nodeId()),
338-
CommonConstant.DATE, List.of(KPI_GRANULARITY_WEEKS)))
339-
.ids(new String[]{String.valueOf(
340-
this.kpiMaturityCalculationConfig.getCalculationConfig().getDataPoints().getCount())})
341-
.level(projectInput.hierarchyLevel())
342-
.label(projectInput.hierarchyLevelId()).build());
343-
case SPRINT, ITERATION, PI -> kpiRequests.add(KpiRequest.builder()
344-
.kpiIdList(new ArrayList<>(entry.getValue().stream().map(KpiMaster::getKpiId).toList()))
345-
.selectedMap(Map.of(CommonConstant.HIERARCHY_LEVEL_ID_SPRINT,
346-
projectInput.sprints().stream().map(SprintInputDTO::nodeId).toList(),
347-
CommonConstant.HIERARCHY_LEVEL_ID_PROJECT, List.of(projectInput.nodeId())))
348-
.ids(projectInput.sprints().stream().map(SprintInputDTO::nodeId).toList()
349-
.toArray(String[]::new))
350-
.level(projectInput.sprints().get(0).hierarchyLevel())
351-
.label(CommonConstant.HIERARCHY_LEVEL_ID_SPRINT).build());
352-
case NONE -> {
353-
if(projectInput.deliveryMethodology() == ProjectDeliveryMethodology.KANBAN) {
354-
kpiRequests.add(KpiRequest.builder()
355-
.kpiIdList(new ArrayList<>(entry.getValue().stream().map(KpiMaster::getKpiId).toList()))
356-
.selectedMap(Map.of(CommonConstant.HIERARCHY_LEVEL_ID_PROJECT, List.of(projectInput.nodeId()),
357-
CommonConstant.DATE, List.of(KPI_GRANULARITY_WEEKS)))
358-
.ids(new String[]{String.valueOf(
359-
this.kpiMaturityCalculationConfig.getCalculationConfig().getDataPoints().getCount())})
360-
.level(projectInput.hierarchyLevel()).label(projectInput.hierarchyLevelId()).build());
361-
} else {
337+
case MONTH, WEEK, DAY -> kpiRequests.add(KpiRequest.builder()
338+
.kpiIdList(new ArrayList<>(entry.getValue().stream().map(KpiMaster::getKpiId).toList()))
339+
.selectedMap(Map.of(CommonConstant.HIERARCHY_LEVEL_ID_PROJECT, List.of(projectInput.nodeId()),
340+
CommonConstant.DATE, List.of(KPI_GRANULARITY_WEEKS)))
341+
.ids(new String[] { String.valueOf(
342+
this.kpiMaturityCalculationConfig.getCalculationConfig().getDataPoints().getCount()) })
343+
.level(projectInput.hierarchyLevel()).label(projectInput.hierarchyLevelId()).build());
344+
case SPRINT, ITERATION, PI -> {
345+
if (CollectionUtils.isNotEmpty(projectInput.sprints())) {
346+
kpiRequests.add(KpiRequest.builder()
347+
.kpiIdList(new ArrayList<>(entry.getValue().stream().map(KpiMaster::getKpiId).toList()))
348+
.selectedMap(Map.of(CommonConstant.HIERARCHY_LEVEL_ID_SPRINT,
349+
projectInput.sprints().stream().map(SprintInputDTO::nodeId).toList(),
350+
CommonConstant.HIERARCHY_LEVEL_ID_PROJECT, List.of(projectInput.nodeId())))
351+
.ids(projectInput.sprints().stream().map(SprintInputDTO::nodeId).toList()
352+
.toArray(String[]::new))
353+
.level(projectInput.sprints().get(0).hierarchyLevel())
354+
.label(CommonConstant.HIERARCHY_LEVEL_ID_SPRINT).build());
355+
}
356+
}
357+
case NONE -> {
358+
if (projectInput.deliveryMethodology() == ProjectDeliveryMethodology.KANBAN) {
359+
kpiRequests.add(KpiRequest.builder()
360+
.kpiIdList(new ArrayList<>(entry.getValue().stream().map(KpiMaster::getKpiId).toList()))
361+
.selectedMap(
362+
Map.of(CommonConstant.HIERARCHY_LEVEL_ID_PROJECT, List.of(projectInput.nodeId()),
363+
CommonConstant.DATE, List.of(KPI_GRANULARITY_WEEKS)))
364+
.ids(new String[] { String.valueOf(this.kpiMaturityCalculationConfig.getCalculationConfig()
365+
.getDataPoints().getCount()) })
366+
.level(projectInput.hierarchyLevel()).label(projectInput.hierarchyLevelId()).build());
367+
} else {
368+
if (CollectionUtils.isNotEmpty(projectInput.sprints())) {
362369
kpiRequests.add(KpiRequest.builder()
363370
.kpiIdList(new ArrayList<>(entry.getValue().stream().map(KpiMaster::getKpiId).toList()))
364371
.selectedMap(Map.of(CommonConstant.HIERARCHY_LEVEL_ID_SPRINT,
@@ -371,6 +378,7 @@ private List<KpiRequest> constructKpiRequests(ProjectInputDTO projectInput) {
371378
}
372379
}
373380
}
381+
}
374382
}
375383
return kpiRequests;
376384
}
@@ -381,7 +389,8 @@ private List<KpiRequest> constructKpiRequests(ProjectInputDTO projectInput) {
381389
* <p>
382390
* This method performs a multi-step filtering process:
383391
* <ol>
384-
* <li>Fetch KPIs supporting maturity calculation for SCRUM and KANBAN methodology</li>
392+
* <li>Fetch KPIs supporting maturity calculation for SCRUM and KANBAN
393+
* methodology</li>
385394
* <li>Map KPI categories from database configuration</li>
386395
* <li>Override categories with values from KpiCategoryMapping if available</li>
387396
* <li>Filter KPIs to include only those with configured category weights</li>
@@ -400,8 +409,7 @@ private List<KpiMaster> loadKpisEligibleForMaturityCalculation() {
400409
}
401410
return KpiMaster.builder().kpiId(kpiMasterProjection.getKpiId())
402411
.kpiName(kpiMasterProjection.getKpiName()).kpiCategory(kpiCategory.toLowerCase())
403-
.kpiSource(kpiMasterProjection.getKpiSource())
404-
.kanban(kpiMasterProjection.isKanban())
412+
.kpiSource(kpiMasterProjection.getKpiSource()).kanban(kpiMasterProjection.isKanban())
405413
.xAxisLabel(kpiMasterProjection.getxAxisLabel()).build();
406414
}).toList();
407415

ai-data-processor/src/main/java/com/publicissapient/kpidashboard/job/productivitycalculation/service/ProjectBatchService.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,21 @@ private static List<ProjectInputDTO> constructProjectInputDTOList(Page<ProjectBa
196196
projectInputDTOBuilder.deliveryMethodology(ProjectDeliveryMethodology.KANBAN)
197197
.sprints(List.of());
198198
} else {
199-
projectInputDTOBuilder.deliveryMethodology(ProjectDeliveryMethodology.SCRUM)
200-
.sprints(projectObjectIdSprintsMap.get(projectBasicConfig.getId()).stream()
201-
.map(sprintDetails -> SprintInputDTO.builder()
202-
.hierarchyLevel(sprintHierarchyLevel.getLevel())
203-
.hierarchyLevelId(sprintHierarchyLevel.getHierarchyLevelId())
204-
.name(sprintDetails.getSprintName()).nodeId(sprintDetails.getSprintID())
205-
.build())
206-
.toList());
199+
projectInputDTOBuilder.deliveryMethodology(ProjectDeliveryMethodology.SCRUM);
200+
if (CollectionUtils.isEmpty(projectObjectIdSprintsMap.get(projectBasicConfig.getId()))) {
201+
log.info("Scrum project with node id {} and name {} did not have any sprint data",
202+
projectBasicConfig.getProjectNodeId(), projectBasicConfig.getProjectName());
203+
projectInputDTOBuilder.sprints(Collections.emptyList());
204+
} else {
205+
projectInputDTOBuilder
206+
.sprints(projectObjectIdSprintsMap.get(projectBasicConfig.getId()).stream()
207+
.map(sprintDetails -> SprintInputDTO.builder()
208+
.hierarchyLevel(sprintHierarchyLevel.getLevel())
209+
.hierarchyLevelId(sprintHierarchyLevel.getHierarchyLevelId())
210+
.name(sprintDetails.getSprintName())
211+
.nodeId(sprintDetails.getSprintID()).build())
212+
.toList());
213+
}
207214
}
208215
return projectInputDTOBuilder.build();
209216
}).toList();

0 commit comments

Comments
 (0)