Allow replay cache to be disabled with env variable

This commit is contained in:
Stedoss 2024-11-03 15:22:33 +00:00
parent 5d44d76671
commit da6aefa74d

View File

@ -55,6 +55,7 @@ class ImportScores(
private val messagingTemplate: SimpMessagingTemplate, private val messagingTemplate: SimpMessagingTemplate,
private val replayCacheService: ReplayCacheService, private val replayCacheService: ReplayCacheService,
) : InitializingBean { ) : InitializingBean {
val replayCacheEnabled = (System.getenv("REPLAY_CACHE_ENABLED") ?: "0") != "0"
private val userToUpdateBucket = mutableListOf<Long>() private val userToUpdateBucket = mutableListOf<Long>()
@ -788,20 +789,22 @@ class ImportScores(
) )
} }
// Insert into replay cache if (replayCacheEnabled) {
val replayCacheReplay = ReplayCacheReplay( // Insert into replay cache
score.best_id, val replayCacheReplay = ReplayCacheReplay(
beatmapId, score.best_id,
score.user_id.toInt(), beatmapId,
Base64.getDecoder().decode(scoreReplay.content), score.user_id.toInt(),
Mod.combineModStrings(score.mods), Base64.getDecoder().decode(scoreReplay.content),
) Mod.combineModStrings(score.mods),
val replayCacheInsertSuccess = replayCacheService.insertReplay(replayCacheReplay) )
val replayCacheInsertSuccess = replayCacheService.insertReplay(replayCacheReplay)
if (replayCacheInsertSuccess) { if (replayCacheInsertSuccess) {
logger.info("Inserted replay ${score.id} into replay cache") logger.info("Inserted replay ${score.id} into replay cache")
} else { } else {
logger.error("Could not insert replay ${score.id} into replay cache") logger.error("Could not insert replay ${score.id} into replay cache")
}
} }
this.statistics.scoresWithReplayAndAnalyzed++ this.statistics.scoresWithReplayAndAnalyzed++