diff --git a/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/FixOldScores.kt b/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/FixOldScores.kt index 897d508..fa5bdc5 100644 --- a/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/FixOldScores.kt +++ b/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/FixOldScores.kt @@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Profile import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Service +import java.time.OffsetDateTime @Profile("fix:scores") @Service @@ -43,9 +44,20 @@ class FixOldScores( data class Task(val offset: Int, val limit: Int) + /** + * This is the minimum cutoff date for scores to be processed. + * You can set a really old date (e.g. 2023-01-01) here to process all scores. + */ + private val minCutoff = OffsetDateTime.of( + 2024, 3, 1, 0, 0, 0, 0, OffsetDateTime.now().offset + ) + @Scheduled(fixedDelay = 120000, initialDelay = 0) fun fixOldScores() { - val condition = SCORES.REPLAY.isNotNull.and(SCORES.VERSION.lessThan(CURRENT_VERSION)) + val condition = SCORES.REPLAY.isNotNull + .and(SCORES.VERSION.lessThan(CURRENT_VERSION)) + .and(SCORES.ADDED_AT.greaterOrEqual(minCutoff)) + val totalRows = dslContext.fetchCount(SCORES, condition) if(totalRows <= 0) { diff --git a/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/SendScoresToDiscord.kt b/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/SendScoresToDiscord.kt index 5facdd5..c7e2b68 100644 --- a/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/SendScoresToDiscord.kt +++ b/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/SendScoresToDiscord.kt @@ -36,7 +36,7 @@ class SendScoresToDiscord( // 2024-03-03 00:00:00 private val minCutoff = OffsetDateTime.of( - 2024, 3, 3, 0, 0, 0, 0, OffsetDateTime.now().offset + 2024, 3, 4, 0, 0, 0, 0, OffsetDateTime.now().offset ) @Scheduled(fixedDelay = 1200000, initialDelay = 0)