Skip to content

Commit

Permalink
Grad2 2540 (#630)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
cditcher and chris.ditcher authored Mar 21, 2024
1 parent 265503f commit 158aed7
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
@@ -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();
}


}
6 changes: 4 additions & 2 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ server:
worker: 128
io: 16
#port: ${HTTP_PORT}
tomcat:
connection-timeout: 200s
#tomcat:
#connection-timeout: 200s

#API Documentation
springdoc:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions api/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tools/config/override-configmap-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
1 change: 1 addition & 0 deletions tools/config/update-configmap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 158aed7

Please sign in to comment.