Search in sources :

Example 1 with SchoolGroupCodes

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();
}
Also used : lombok.val(lombok.val) PenRequestBatchStat(ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatchStat) SchoolGroupCodes(ca.bc.gov.educ.penreg.api.constants.SchoolGroupCodes) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SchoolGroupCodes (ca.bc.gov.educ.penreg.api.constants.SchoolGroupCodes)1 PenRequestBatchStat (ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatchStat)1 lombok.val (lombok.val)1 Transactional (org.springframework.transaction.annotation.Transactional)1