mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 01:53:19 +01:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user