feat: NCS-82 add Swiss-system tournament module #55

Merged
lq64 merged 11 commits from feat/NCS-82 into main 2026-06-09 15:09:53 +02:00
Showing only changes of commit 4d54122d24 - Show all commits
1
@@ -201,26 +201,22 @@ class AccountService:
@Transactional
def createOfficialBotAccount(botName: String): Either[AccountError, OfficialBotAccount] =
val id = UUID.randomUUID()
val bot = new OfficialBotAccount()
bot.id = id
bot.name = botName
bot.createdAt = Instant.now()
bot.token = generateBotToken(id, botName)
officialBotAccountRepository.persist(bot)
bot.token = generateBotToken(bot.id, botName)
Outdated
Review

Same two-persist pattern. The root cause is that bot.id is not available before the first persist(). Either use a pre-assigned UUID (@Id with UUID.randomUUID() before persist) or derive the token from a field that doesn't require a DB round-trip. Two flushes per creation is a correctness risk under failure: if the second persist fails, the entity exists without a valid token.

Same two-persist pattern. The root cause is that bot.id is not available before the first persist(). Either use a pre-assigned UUID (@Id with UUID.randomUUID() before persist) or derive the token from a field that doesn't require a DB round-trip. Two flushes per creation is a correctness risk under failure: if the second persist fails, the entity exists without a valid token.
Right(bot)
@Transactional
def syncOfficialBots(botNames: List[String]): Unit =
botNames.foreach { name =>
if officialBotAccountRepository.findByName(name).isEmpty then
val id = UUID.randomUUID()
val bot = new OfficialBotAccount()
bot.id = id
bot.name = name
bot.createdAt = Instant.now()
bot.token = generateBotToken(id, name)
officialBotAccountRepository.persist(bot)
bot.token = generateBotToken(bot.id, name)
log.infof("Auto-registered official bot: %s", name)
}
1