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
2 changed files with 5 additions and 3 deletions
Showing only changes of commit 2d9ceca097 - Show all commits
@@ -76,6 +76,6 @@ class OfficialBotAccount extends PanacheEntityBase:
var createdAt: Instant = uninitialized
Outdated
Review

Missing nullable = false. A just-constructed OfficialBotAccount starts with token = uninitialized, and AccountService does two separate persist() calls to work around this. Add nullable = false and generate the token before the first persist to collapse it to one round-trip and make the constraint explicit at the DB level.

Missing nullable = false. A just-constructed OfficialBotAccount starts with token = uninitialized, and AccountService does two separate persist() calls to work around this. Add nullable = false and generate the token before the first persist to collapse it to one round-trip and make the constraint explicit at the DB level.
@Column(nullable = false, length = 1024)
@Column(length = 1024)
var token: String = uninitialized
// scalafix:on
1
@@ -205,7 +205,8 @@ class AccountService:
bot.name = botName
bot.createdAt = Instant.now()
officialBotAccountRepository.persist(bot)
bot.token = generateBotToken(bot.id, botName)
bot.token = generateBotToken(bot.id, bot.name)
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.
officialBotAccountRepository.persist(bot)
Right(bot)
@Transactional
@@ -216,7 +217,8 @@ class AccountService:
bot.name = name
bot.createdAt = Instant.now()
officialBotAccountRepository.persist(bot)
bot.token = generateBotToken(bot.id, name)
bot.token = generateBotToken(bot.id, bot.name)
officialBotAccountRepository.persist(bot)
log.infof("Auto-registered official bot: %s", name)
}
1