-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grad release 1.12.0
- Loading branch information
Showing
14 changed files
with
186 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dc/GradStatusPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package ca.bc.gov.educ.api.gradstudent.model.dc; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public class GradStatusPayload { | ||
|
||
private String program; | ||
private String programCompletionDate; | ||
private String exception; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
api/src/main/java/ca/bc/gov/educ/api/gradstudent/scheduler/PurgeOldRecordsScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package ca.bc.gov.educ.api.gradstudent.scheduler; | ||
|
||
import ca.bc.gov.educ.api.gradstudent.repository.GradStatusEventRepository; | ||
import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants; | ||
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.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Component | ||
@Slf4j | ||
public class PurgeOldRecordsScheduler { | ||
private final GradStatusEventRepository gradStatusEventRepository; | ||
private final EducGradStudentApiConstants constants; | ||
|
||
public PurgeOldRecordsScheduler(final GradStatusEventRepository gradStatusEventRepository, | ||
final EducGradStudentApiConstants constants) { | ||
this.gradStatusEventRepository = gradStatusEventRepository; | ||
this.constants = constants; | ||
} | ||
|
||
@Scheduled(cron = "${cron.scheduled.process.purge-old-records.run}") | ||
@SchedulerLock(name = "PurgeOldRecordsLock", | ||
lockAtLeastFor = "PT1H", lockAtMostFor = "PT1H") //midnight job so lock for an hour | ||
@Transactional | ||
public void purgeOldRecords() { | ||
LockAssert.assertLocked(); | ||
final LocalDateTime createDateToCompare = this.calculateCreateDateBasedOnStaleEventInDays(); | ||
this.gradStatusEventRepository.deleteByCreateDateBefore(createDateToCompare); | ||
} | ||
|
||
private LocalDateTime calculateCreateDateBasedOnStaleEventInDays() { | ||
final LocalDateTime currentTime = LocalDateTime.now(); | ||
return currentTime.minusDays(this.constants.getRecordsStaleInDays()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.