refactor(channelserver): standardize on BeginTxx for all repository transactions

Replace db.Begin() with db.BeginTxx(context.Background(), nil) across all
8 remaining call sites in repo_guild.go, repo_guild_rp.go, repo_festa.go,
and repo_event.go. Use deferred Rollback() instead of explicit rollback
at each error return, eliminating 15 manual rollback calls.
This commit is contained in:
Houmgaor
2026-02-22 16:55:59 +01:00
parent 2acbb5d03a
commit 59fd722d37
5 changed files with 30 additions and 38 deletions

View File

@@ -1,6 +1,7 @@
package channelserver
import (
"context"
"time"
"github.com/jmoiron/sqlx"
@@ -79,13 +80,14 @@ func (r *EventRepository) UpdateEventQuestStartTimes(updates []EventQuestUpdate)
if len(updates) == 0 {
return nil
}
tx, err := r.db.Begin()
tx, err := r.db.BeginTxx(context.Background(), nil)
if err != nil {
return err
}
defer func() { _ = tx.Rollback() }()
for _, u := range updates {
if _, err := tx.Exec("UPDATE event_quests SET start_time = $1 WHERE id = $2", u.StartTime, u.ID); err != nil {
_ = tx.Rollback()
return err
}
}