Skip to content

Commit

Permalink
feat: add endpoint /report-data/real-world-testing/plans
Browse files Browse the repository at this point in the history
OCD-4517
  • Loading branch information
tmy1313 committed Jan 4, 2025
1 parent b3e81ba commit 25d64fc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,23 @@ public RealWorldTestingReportController(ReportDataManager reportDataManager) {
this.reportDataManager = reportDataManager;
}

@Operation(summary = "Retrieves the data used to generate the Standard Criteria Attribute Summary report.",
description = "Retrieves the data used to generate the Standard Criteria Attribute Summary report.",
@Operation(summary = "Retrieves the data used to generate the Real World Testing Plans report.",
description = "Retrieves the data used to generate the Real World Testing Plans report.",
security = {
@SecurityRequirement(name = SwaggerSecurityRequirement.API_KEY)
})
@RequestMapping(value = "/plans", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
public @ResponseBody List<RealWorldTestingSummaryReport> getRealWorldTestingPlanReports() {
return reportDataManager.getRealWorldTestingReportDataService().getRealWorldTestingPlanSummaryReports();
}

@Operation(summary = "Retrieves the data used to generate the Real World Testing Results report.",
description = "Retrieves the data used to generate the Real World Testing Results report.",
security = {
@SecurityRequirement(name = SwaggerSecurityRequirement.API_KEY)
})
@RequestMapping(value = "/results", method = RequestMethod.GET, produces = "application/json; charset=utf-8")
public @ResponseBody List<RealWorldTestingSummaryReport> getRealWorldTestingResultsReports() {
return reportDataManager.getRealWorldTestingReportDataService().getRealWorldTestingResultsSummaryReports();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@ public List<RealWorldTestingSummaryReport> getRealWorldTestingPlanSummaryReports
return List.of();
}
}

@Transactional
public List<RealWorldTestingSummaryReport> getRealWorldTestingResultsSummaryReports() {
Optional<Long> rwtYear = realWorldTestingResultsSummaryReportDao.getMaxRealWorldTestingYear();
if (rwtYear.isPresent()) {
return realWorldTestingResultsSummaryReportDao.getRealWorldTestingReportsByTestingYear(rwtYear.get());
} else {
return List.of();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -34,6 +35,21 @@ public void save(RealWorldTestingSummaryReport realWorldTestingSummaryReport) th
}
}

public Optional<Long> getMaxRealWorldTestingYear() {
return Optional.ofNullable(entityManager.createQuery(
"select MAX(rwtrsr.realWorldTestingYear) "
+ "from RealWorldTestingResultsSummaryReportEntity rwtrsr "
+ "where (NOT deleted = true)", Long.class)
.getSingleResult());

}

public List<RealWorldTestingSummaryReport> getRealWorldTestingReportsByTestingYear(Long realWorldTestingYear) {
return getEntitiesByRealWorldTestingYear(realWorldTestingYear).stream()
.map(entity -> entity.toDomain())
.toList();
}

private RealWorldTestingResultsSummaryReportEntity getEntity(Long id) throws EntityRetrievalException {
Query query = entityManager.createQuery(
"from RealWorldTestingResultsSummaryReportEntity where (NOT deleted = true) and id = :id", RealWorldTestingResultsSummaryReportEntity.class);
Expand Down Expand Up @@ -70,4 +86,13 @@ private RealWorldTestingResultsSummaryReportEntity getEntityByCheckedDateAndAcb(
return null;
}

private List<RealWorldTestingResultsSummaryReportEntity> getEntitiesByRealWorldTestingYear(Long testingYear){
return entityManager.createQuery(
"from RealWorldTestingResultsSummaryReportEntity rwtrs "
+ "where (NOT deleted = true) "
+ "and rwtrs.realWorldTestingYear = :realWorldTestingYear", RealWorldTestingResultsSummaryReportEntity.class)
.setParameter("realWorldTestingYear", testingYear)
.getResultList();
}

}

0 comments on commit 25d64fc

Please sign in to comment.