use of ca.bc.gov.educ.penreg.api.constants.SchoolGroupCodes in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchService method getStats.
/**
* Gets stats.
*
* @return the stats
*/
@Transactional(propagation = Propagation.SUPPORTS)
public PenRequestBatchStats getStats() {
final List<PenRequestBatchStat> penRequestBatchStats = new ArrayList<>();
for (final SchoolGroupCodes schoolGroupCode : SchoolGroupCodes.values()) {
val results = this.getRepository().findByPenRequestBatchStatusCodeAndSchoolGroupCode(PenRequestBatchStatusCodes.ACTIVE.getCode(), schoolGroupCode.getCode());
final PenRequestBatchStat stats = this.calculateFixableAndRepeats(results);
stats.setSchoolGroupCode(schoolGroupCode.getCode());
List<String> penReqBatchStatusCodes = Arrays.asList(PenRequestBatchStatusCodes.UNARCHIVED.getCode(), PenRequestBatchStatusCodes.UNARCHIVED_CHANGED.getCode());
stats.setUnarchivedCount(this.getRepository().countAllByPenRequestBatchStatusCodeInAndSchoolGroupCode(penReqBatchStatusCodes, schoolGroupCode.getCode()));
if (schoolGroupCode == SchoolGroupCodes.PSI) {
penReqBatchStatusCodes = Arrays.asList(PenRequestBatchStatusCodes.HOLD_FOR_REVIEW.getCode(), PenRequestBatchStatusCodes.DUPLICATE.getCode());
stats.setHeldForReviewCount(this.getRepository().countAllByPenRequestBatchStatusCodeInAndSchoolGroupCode(penReqBatchStatusCodes, schoolGroupCode.getCode()));
} else {
stats.setHeldForReviewCount(0L);
}
penRequestBatchStats.add(stats);
}
// this is irrespective of school group code.
val loadFailedCount = this.getRepository().countPenRequestBatchEntitiesByPenRequestBatchStatusCode(PenRequestBatchStatusCodes.LOAD_FAIL.getCode());
return PenRequestBatchStats.builder().penRequestBatchStatList(penRequestBatchStats).loadFailCount(loadFailedCount).build();
}
Aggregations