Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRAD2-1893 #429

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public class DistributionRunPartitioner extends BasePartitioner {

private static final Logger LOGGER = LoggerFactory.getLogger(DistributionRunPartitioner.class);
private static final Logger logger = LoggerFactory.getLogger(DistributionRunPartitioner.class);

@Value("#{stepExecution.jobExecution}")
JobExecution context;
Expand All @@ -29,23 +29,18 @@ public class DistributionRunPartitioner extends BasePartitioner {

@Override
public Map<String, ExecutionContext> partition(int gridSize) {
ResponseObj res = restUtils.getTokenResponseObject();
String accessToken = null;
if (res != null) {
accessToken = res.getAccess_token();
}

// Clean up existing reports before running new one
LOGGER.debug("Delete School Reports for Monthly Distribution");
logger.debug("Delete School Reports for Monthly Distribution");
long startTime = System.currentTimeMillis();
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL", restUtils.getAccessToken());
long endTime = System.currentTimeMillis();
long diff = (endTime - startTime)/1000;
LOGGER.debug("Old School Reports deleted in {} sec", diff);
logger.debug("Old School Reports deleted in {} sec", diff);

startTime = System.currentTimeMillis();
LOGGER.debug("Retrieve students for Monthly Distribution");
Mono<DistributionDataParallelDTO> parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(accessToken);
logger.debug("Retrieve students for Monthly Distribution");
Mono<DistributionDataParallelDTO> parallelDTOMono = parallelDataFetch.fetchDistributionRequiredData(restUtils.getAccessToken());
DistributionDataParallelDTO parallelDTO = parallelDTOMono.block();
List<StudentCredentialDistribution> credentialList = new ArrayList<>();
if(parallelDTO != null) {
Expand All @@ -54,20 +49,13 @@ public Map<String, ExecutionContext> partition(int gridSize) {
}
endTime = System.currentTimeMillis();
diff = (endTime - startTime)/1000;
LOGGER.debug("Total {} eligible StudentCredentialDistributions found in {} sec", credentialList.size(), diff);
logger.debug("Total {} eligible StudentCredentialDistributions found in {} sec", credentialList.size(), diff);
if(!credentialList.isEmpty()) {
LOGGER.debug("Total size of credential list: {}", credentialList.size());
// Filter deceased students out
List<UUID> deceasedIDs = restUtils.getDeceasedStudentIDs(credentialList.stream().map(StudentCredentialDistribution::getStudentID).distinct().toList(), restUtils.getAccessToken());
if (!deceasedIDs.isEmpty()) {
LOGGER.debug("Deceased students: {}", deceasedIDs.size());
credentialList.removeIf(cr -> deceasedIDs.contains(cr.getStudentID()));
LOGGER.debug("Revised size of credential list: {}", credentialList.size());
}
filterOutDeceasedStudents(credentialList);
updateBatchJobHistory(createBatchJobHistory(), (long) credentialList.size());
return getStringExecutionContextMap(gridSize, credentialList, null);
}
LOGGER.info("No Credentials Found for Processing");
logger.info("No Credentials Found for Processing");
return new HashMap<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import org.springframework.beans.factory.annotation.Value;
import reactor.core.publisher.Mono;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

public class DistributionRunSupplementalPartitioner extends BasePartitioner {

Expand All @@ -31,28 +28,22 @@ public Map<String, ExecutionContext> partition(int gridSize) {

logger.debug("Delete School Reports for Supplemental Distribution");
long startTime = System.currentTimeMillis();
String accessToken = restUtils.getAccessToken();
// Clean up existing reports before running new one
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL", accessToken);
restUtils.deleteSchoolReportRecord("", "DISTREP_SC", accessToken);
restUtils.deleteSchoolReportRecord("", "ADDRESS_LABEL_SCHL", restUtils.getAccessToken());
restUtils.deleteSchoolReportRecord("", "DISTREP_SC", restUtils.getAccessToken());
long endTime = System.currentTimeMillis();
long diff = (endTime - startTime)/1000;
logger.debug("Old School Reports deleted in {} sec", diff);

startTime = System.currentTimeMillis();
logger.debug("Retrieve students for Supplemental Distribution");
Mono<DistributionDataParallelDTO> parallelDTOMono = parallelDataFetch.fetchDistributionRequiredDataYearly(accessToken);
DistributionDataParallelDTO parallelDTO = parallelDTOMono.block();
List<StudentCredentialDistribution> eligibleStudentSchoolDistricts = new ArrayList<>();
if(parallelDTO != null) {
eligibleStudentSchoolDistricts.addAll(parallelDTO.transcriptList());
eligibleStudentSchoolDistricts.addAll(parallelDTO.certificateList());
}
List<StudentCredentialDistribution> eligibleStudentSchoolDistricts = parallelDataFetch.fetchStudentCredentialsDistributionDataYearly();
endTime = System.currentTimeMillis();
diff = (endTime - startTime)/1000;
logger.debug("Total {} eligible StudentCredentialDistributions found in {} sec", eligibleStudentSchoolDistricts.size(), diff);
filterByStudentSearchRequest(eligibleStudentSchoolDistricts);
if(!eligibleStudentSchoolDistricts.isEmpty()) {
filterOutDeceasedStudents(eligibleStudentSchoolDistricts);
updateBatchJobHistory(createBatchJobHistory(), (long) eligibleStudentSchoolDistricts.size());
return getStringExecutionContextMap(gridSize, eligibleStudentSchoolDistricts, null);
}
Expand Down