From a0ebf676ce5094aa8439e545f9c6df000f2ee7b3 Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Thu, 29 Feb 2024 08:33:39 -0700 Subject: [PATCH 1/4] Adding Student Note Deletion by StudentID for Data Conversion --- .../api/gradstudent/repository/StudentNoteRepository.java | 2 ++ .../api/gradstudent/service/DataConversionService.java | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/StudentNoteRepository.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/StudentNoteRepository.java index 6f9beca6..d883c2b6 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/StudentNoteRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/StudentNoteRepository.java @@ -11,4 +11,6 @@ public interface StudentNoteRepository extends JpaRepository { List findByStudentID(UUID studentId); + + void deleteByStudentID(UUID studentID); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java index fb57faf3..ca504475 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java @@ -11,7 +11,6 @@ import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants; import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiUtils; import ca.bc.gov.educ.api.gradstudent.util.GradValidation; -import ca.bc.gov.educ.api.gradstudent.util.ThreadLocalStateUtil; import io.github.resilience4j.retry.annotation.Retry; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -51,6 +50,7 @@ public class DataConversionService { final StudentOptionalProgramHistoryRepository gradStudentOptionalProgramHistoryRepository; final GraduationStudentRecordHistoryRepository gradStudentRecordHistoryRepository; final HistoryService historyService; + final StudentNoteRepository studentNoteRepository; final GraduationStatusService graduationStatusService; final GradValidation validation; @@ -64,7 +64,7 @@ public DataConversionService(WebClient webClient, StudentCareerProgramRepository gradStudentCareerProgramRepository, GradStudentCareerProgramTransformer gradStudentCareerProgramTransformer, StudentOptionalProgramHistoryRepository gradStudentOptionalProgramHistoryRepository, GraduationStudentRecordHistoryRepository gradStudentRecordHistoryRepository, - HistoryService historyService, GraduationStatusService graduationStatusService, GradValidation validation, EducGradStudentApiConstants constants) { + HistoryService historyService, StudentNoteRepository studentNoteRepository, GraduationStatusService graduationStatusService, GradValidation validation, EducGradStudentApiConstants constants) { this.webClient = webClient; this.graduationStatusRepository = graduationStatusRepository; this.graduationStatusTransformer = graduationStatusTransformer; @@ -75,6 +75,7 @@ public DataConversionService(WebClient webClient, this.gradStudentOptionalProgramHistoryRepository = gradStudentOptionalProgramHistoryRepository; this.gradStudentRecordHistoryRepository = gradStudentRecordHistoryRepository; this.historyService = historyService; + this.studentNoteRepository = studentNoteRepository; this.graduationStatusService = graduationStatusService; this.validation = validation; this.constants = constants; @@ -215,6 +216,8 @@ public void deleteGraduationStatus(UUID studentID) { @Transactional public void deleteAllDependencies(UUID studentID) { + // student_record_note + studentNoteRepository.deleteByStudentID(studentID); // student_career_program gradStudentCareerProgramRepository.deleteByStudentID(studentID); // student_optional_program_history From 158aed7df167197697d700b294d3f04591cc1530 Mon Sep 17 00:00:00 2001 From: Chris Ditcher Date: Thu, 21 Mar 2024 08:33:45 -0700 Subject: [PATCH 2/4] Grad2 2540 (#630) * Added scheduler to update RECALCULATE_PROJECTED_GRAD for students with selected criteria * Modified query as per Kim * Fixed unit tests --------- Co-authored-by: chris.ditcher --- .../GraduationStudentRecordRepository.java | 4 +++ .../RefreshNonGradStatusScheduler.java | 32 +++++++++++++++++++ api/src/main/resources/application.yaml | 6 ++-- api/src/test/resources/application.yaml | 2 ++ tools/config/override-configmap-dev.sh | 1 + tools/config/update-configmap.sh | 1 + 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 api/src/main/java/ca/bc/gov/educ/api/gradstudent/scheduler/RefreshNonGradStatusScheduler.java diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java index 9e84a7d2..4cc26667 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordRepository.java @@ -87,4 +87,8 @@ void updateStudentGuidPenXrefRecord( @Modifying @Query("update GraduationStudentRecordEntity e set e.recalculateGradStatus = :recalculateGradStatus where e.studentID = :studentGuid") void updateGradStudentRecalculationRecalculateGradStatusFlag(@Param(value = "studentGuid") UUID studentGuid, @Param(value = "recalculateGradStatus") String recalculateGradStatus); + + @Modifying + @Query( "update GraduationStudentRecordEntity e set e.recalculateProjectedGrad = 'Y' where e.studentStatus = 'CUR' and e.programCompletionDate is null and (e.studentGrade = '12' or e.studentGrade = 'AD')") + void updateGradStudentRecalcFlagsForCurrentStudentsWithNullCompletion(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/scheduler/RefreshNonGradStatusScheduler.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/scheduler/RefreshNonGradStatusScheduler.java new file mode 100644 index 00000000..e48c61d6 --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/scheduler/RefreshNonGradStatusScheduler.java @@ -0,0 +1,32 @@ +package ca.bc.gov.educ.api.gradstudent.scheduler; + +import ca.bc.gov.educ.api.gradstudent.repository.GraduationStudentRecordRepository; +import jakarta.transaction.Transactional; +import lombok.extern.slf4j.Slf4j; +import net.javacrumbs.shedlock.core.LockAssert; +import net.javacrumbs.shedlock.spring.annotation.SchedulerLock; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class RefreshNonGradStatusScheduler { + private final GraduationStudentRecordRepository graduationStudentRecordRepository; + + @Autowired + public RefreshNonGradStatusScheduler(GraduationStudentRecordRepository graduationStudentRecordRepository) { + this.graduationStudentRecordRepository = graduationStudentRecordRepository; + } + + @Scheduled(cron = "${cron.scheduled.process.refresh-non-grad-status.run}") + @SchedulerLock(name = "refreshNonGradStatusLock", + lockAtLeastFor = "PT2M", lockAtMostFor = "PT5M") + @Transactional + public void refreshNonGradStatuses() { + LockAssert.assertLocked(); + graduationStudentRecordRepository.updateGradStudentRecalcFlagsForCurrentStudentsWithNullCompletion(); + } + + +} diff --git a/api/src/main/resources/application.yaml b/api/src/main/resources/application.yaml index 7276e085..e577306e 100644 --- a/api/src/main/resources/application.yaml +++ b/api/src/main/resources/application.yaml @@ -79,8 +79,8 @@ server: worker: 128 io: 16 #port: ${HTTP_PORT} - tomcat: - connection-timeout: 200s + #tomcat: + #connection-timeout: 200s #API Documentation springdoc: @@ -109,6 +109,8 @@ cron: purge-old-records: run: ${CRON_SCHEDULED_PURGE_OLD_RECORDS} staleInDays: ${RECORDS_STALE_IN_DAYS} + refresh-non-grad-status: + run: ${CRON_SCHEDULED_REFRESH_NON_GRAD_STATUS} #Resilience resilience4j.retry: diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml index 85f9516f..de36ae5a 100644 --- a/api/src/test/resources/application.yaml +++ b/api/src/test/resources/application.yaml @@ -98,6 +98,8 @@ cron: purge-old-records: run: 0 30 0 * * * staleInDays: 90 + refresh-non-grad-status: + run: 0 30 0 * * * #Endpoint properties endpoint: diff --git a/tools/config/override-configmap-dev.sh b/tools/config/override-configmap-dev.sh index fc07044d..8e9fd6c4 100644 --- a/tools/config/override-configmap-dev.sh +++ b/tools/config/override-configmap-dev.sh @@ -44,4 +44,5 @@ echo Creating config map "$APP_NAME"-flb-sc-config-map oc create -n "$GRAD_NAMESPACE"-"$envValue" configmap "$APP_NAME"-flb-sc-config-map \ --from-literal=fluent-bit.conf="$FLB_CONFIG" \ --from-literal=parsers.conf="$PARSER_CONFIG" \ + --from-literal=CRON_SCHEDULED_REFRESH_NON_GRAD_STATUS="0 */10 * ? * *" --dry-run=client -o yaml | oc apply -f - diff --git a/tools/config/update-configmap.sh b/tools/config/update-configmap.sh index 8206fd0c..8f28d778 100644 --- a/tools/config/update-configmap.sh +++ b/tools/config/update-configmap.sh @@ -65,6 +65,7 @@ oc create -n "$GRAD_NAMESPACE"-"$envValue" configmap "$APP_NAME"-config-map \ --from-literal=MAXIMUM_POOL_SIZE="20" \ --from-literal=MAX_RETRY_ATTEMPTS="3" \ --from-literal=PEN_API="http://student-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/" \ + --from-literal=CRON_SCHEDULED_REFRESH_NON_GRAD_STATUS="0 0 0 1 * ?" \ --dry-run=client -o yaml | oc apply -f - echo Creating config map "$APP_NAME"-flb-sc-config-map From bc4ecb9841b147c1aa30c5e3497b2e192dab2f4d Mon Sep 17 00:00:00 2001 From: Chris Ditcher Date: Thu, 21 Mar 2024 09:13:17 -0700 Subject: [PATCH 3/4] GRAD2-2540 fixed update to dev config map (#632) * Added scheduler to update RECALCULATE_PROJECTED_GRAD for students with selected criteria * Modified query as per Kim * Fixed unit tests * Fixed update configmaps for dev --------- Co-authored-by: chris.ditcher --- tools/config/override-configmap-dev.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/config/override-configmap-dev.sh b/tools/config/override-configmap-dev.sh index 8e9fd6c4..81b8dcd6 100644 --- a/tools/config/override-configmap-dev.sh +++ b/tools/config/override-configmap-dev.sh @@ -40,6 +40,25 @@ PARSER_CONFIG=" ########################################################### #Override config-maps in DEV ########################################################### +echo Creating config map "$APP_NAME"-config-map +oc create -n "$GRAD_NAMESPACE"-"$envValue" configmap "$APP_NAME"-config-map \ + --from-literal=APP_LOG_LEVEL="$APP_LOG_LEVEL" \ + --from-literal=CONNECTION_TIMEOUT="60000" \ + --from-literal=EDUC_SCHOOL_API="http://school-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/" \ + --from-literal=ENABLE_FLYWAY="true" \ + --from-literal=ENABLE_SPLUNK_LOG_HELPER="false" \ + --from-literal=ENABLE_STUDENT_ID_PEN_XREF="true" \ + --from-literal=ENABLE_TRAX_UPDATE="true" \ + --from-literal=GRAD_GRADUATION_REPORT_API="http://educ-grad-graduation-report-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ + --from-literal=GRAD_PROGRAM_API="http://educ-grad-program-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ + --from-literal=GRAD_STUDENT_GRADUATION_API="http://educ-grad-student-graduation-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/" \ + --from-literal=GRAD_TRAX_API="http://educ-grad-trax-api.$GRAD_NAMESPACE-$envValue.svc.cluster.local:8080/"\ + --from-literal=MAXIMUM_POOL_SIZE="20" \ + --from-literal=MAX_RETRY_ATTEMPTS="3" \ + --from-literal=PEN_API="http://student-api-master.$COMMON_NAMESPACE-$envValue.svc.cluster.local:8080/" \ + --from-literal=CRON_SCHEDULED_REFRESH_NON_GRAD_STATUS="0 */10 * ? * *" \ + --dry-run=client -o yaml | oc apply -f - + echo Creating config map "$APP_NAME"-flb-sc-config-map oc create -n "$GRAD_NAMESPACE"-"$envValue" configmap "$APP_NAME"-flb-sc-config-map \ --from-literal=fluent-bit.conf="$FLB_CONFIG" \ From 7a4723e46fc4b4183654290be380eb4b37a13c31 Mon Sep 17 00:00:00 2001 From: githubmamatha <106563495+githubmamatha@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:52:15 -0700 Subject: [PATCH 4/4] Update pom.xml --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index 51c04c13..9f431e35 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ ca.bc.gov.educ educ-grad-student-api - 1.8.55 + 1.8.56 educ-grad-student-api Student Demographics API for GRAD team