[F] Fix results not saved

This commit is contained in:
Azalea
2024-04-18 12:30:36 +09:00
parent bf7de99524
commit 4f05365da3

View File

@@ -151,7 +151,8 @@ class CardGameService(
val wacca: WcUserRepo, val wacca: WcUserRepo,
val ongeki: icu.samnyan.aqua.sega.ongeki.dao.userdata.UserDataRepository, val ongeki: icu.samnyan.aqua.sega.ongeki.dao.userdata.UserDataRepository,
val diva: icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository, val diva: icu.samnyan.aqua.sega.diva.dao.userdata.PlayerProfileRepository,
val safety: AquaNetSafetyService val safety: AquaNetSafetyService,
val cardRepo: CardRepository
) { ) {
companion object { companion object {
val log = logger() val log = logger()
@@ -188,17 +189,17 @@ class CardGameService(
) } ) }
// Every hour // Every hour
@Suppress("UNCHECKED_CAST")
@Scheduled(fixedDelay = 3600000) @Scheduled(fixedDelay = 3600000)
suspend fun autoBan() { suspend fun autoBan() {
log.info("Running auto-ban") log.info("Running auto-ban")
// Ban any players with unacceptable names // Ban any players with unacceptable names
for (repo in listOf(maimai2, chusan, wacca, ongeki)) { for (repo in listOf(maimai2, chusan, wacca, ongeki)) {
repo.findAll().filter { it.card != null }.forEach { data -> repo.findAll().filter { it.card != null && !it.card!!.rankingBanned }.forEach { data ->
if (!safety.isSafe(data.userName)) { if (!safety.isSafe(data.userName)) {
log.info("Banning user ${data.userName} ${data.card!!.id}")
data.card!!.rankingBanned = true data.card!!.rankingBanned = true
async { (repo as GenericUserDataRepo<IUserData>).save(data) } async { cardRepo.save(data.card!!) }
} }
} }
} }