refactor(festa): extract festa logic into FestaService

The festa handler contained event lifecycle management (cleanup expired
events, create new ones) and the repo enforced a business rule (skip
zero-value soul submissions). Move these into a new FestaService to
keep repos as pure data access and consolidate business logic.
This commit is contained in:
Houmgaor
2026-02-24 16:12:40 +01:00
parent 7a56810e78
commit 4d3ec8164c
7 changed files with 231 additions and 20 deletions

View File

@@ -181,6 +181,7 @@ func (r *FestaRepository) RegisterGuild(guildID uint32, team string) error {
}
// SubmitSouls records soul submissions for a character within a transaction.
// All entries are inserted; callers should pre-filter zero values.
func (r *FestaRepository) SubmitSouls(charID, guildID uint32, souls []uint16) error {
tx, err := r.db.BeginTxx(context.Background(), nil)
if err != nil {
@@ -189,9 +190,6 @@ func (r *FestaRepository) SubmitSouls(charID, guildID uint32, souls []uint16) er
defer func() { _ = tx.Rollback() }()
for i, s := range souls {
if s == 0 {
continue
}
if _, err := tx.Exec(`INSERT INTO festa_submissions VALUES ($1, $2, $3, $4, now())`, charID, guildID, i, s); err != nil {
return err
}