Persist beatmap file to database in fix old scores, min discord cutoff after fix

This commit is contained in:
nise.moe 2024-03-04 00:02:18 +01:00
parent df35787be2
commit bafe15f6ea
2 changed files with 12 additions and 0 deletions

View File

@ -118,6 +118,11 @@ class FixOldScores(
if(beatmapFile == null) { if(beatmapFile == null) {
this.logger.error("Failed to fetch beatmap file for beatmap_id = ${score.beatmapId} from osu!api") this.logger.error("Failed to fetch beatmap file for beatmap_id = ${score.beatmapId} from osu!api")
return return
} else {
dslContext.update(BEATMAPS)
.set(BEATMAPS.BEATMAP_FILE, beatmapFile)
.where(BEATMAPS.BEATMAP_ID.eq(score.beatmapId))
.execute()
} }
} }

View File

@ -18,6 +18,7 @@ import org.springframework.context.annotation.Profile
import org.springframework.scheduling.annotation.Scheduled import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import java.time.LocalDateTime import java.time.LocalDateTime
import java.time.OffsetDateTime
import kotlin.math.roundToInt import kotlin.math.roundToInt
@Profile("discord") @Profile("discord")
@ -33,11 +34,17 @@ class SendScoresToDiscord(
private val logger = LoggerFactory.getLogger(javaClass) private val logger = LoggerFactory.getLogger(javaClass)
// 2024-03-03 00:00:00
private val minCutoff = OffsetDateTime.of(
2024, 3, 3, 0, 0, 0, 0, OffsetDateTime.now().offset
)
@Scheduled(fixedDelay = 1200000, initialDelay = 0) @Scheduled(fixedDelay = 1200000, initialDelay = 0)
fun sendScoresToDiscord() { fun sendScoresToDiscord() {
dslContext.selectFrom(SCORES) dslContext.selectFrom(SCORES)
.where(SCORES.SENT_DISCORD_NOTIFICATION.isFalse) .where(SCORES.SENT_DISCORD_NOTIFICATION.isFalse)
.or(SCORES.SENT_DISCORD_NOTIFICATION.isNull) .or(SCORES.SENT_DISCORD_NOTIFICATION.isNull)
.and(SCORES.ADDED_AT.greaterOrEqual(minCutoff))
.and(SCORES.ADJUSTED_UR.isNotNull) .and(SCORES.ADJUSTED_UR.isNotNull)
.and(SCORES.ADJUSTED_UR.lessOrEqual(25.0)) .and(SCORES.ADJUSTED_UR.lessOrEqual(25.0))
.and(SCORES.IS_BANNED.isFalse) .and(SCORES.IS_BANNED.isFalse)