mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
refactor(channelserver): eliminate *sqlx.Rows/*sql.Rows from repository interfaces
Move scan loops from handlers into repository methods so that interfaces return typed slices instead of leaking database cursors. This fixes resource leaks (7 of 12 call sites never closed rows) and makes all 12 methods mockable for unit tests. Affected repos: CafeRepo, ShopRepo, EventRepo, RengokuRepo, DivaRepo, ScenarioRepo, MiscRepo, MercenaryRepo. New structs: DivaEvent, MercenaryLoan, GuildHuntCatUsage. EventRepo.GetEventQuests left as-is (requires broader Server refactor).
This commit is contained in:
@@ -26,7 +26,15 @@ func (r *DivaRepository) InsertEvent(startEpoch uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// GetEvents returns all diva events with their ID and start_time epoch.
|
||||
func (r *DivaRepository) GetEvents() (*sqlx.Rows, error) {
|
||||
return r.db.Queryx("SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='diva'")
|
||||
// DivaEvent represents a diva event row with ID and start_time epoch.
|
||||
type DivaEvent struct {
|
||||
ID uint32 `db:"id"`
|
||||
StartTime uint32 `db:"start_time"`
|
||||
}
|
||||
|
||||
// GetEvents returns all diva events with their ID and start_time epoch.
|
||||
func (r *DivaRepository) GetEvents() ([]DivaEvent, error) {
|
||||
var result []DivaEvent
|
||||
err := r.db.Select(&result, "SELECT id, (EXTRACT(epoch FROM start_time)::int) as start_time FROM events WHERE event_type='diva'")
|
||||
return result, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user