everybody loves a refactor
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"git.haelnorr.com/h/oslstats/internal/db"
|
||||
"git.haelnorr.com/h/oslstats/internal/notify"
|
||||
"git.haelnorr.com/h/oslstats/internal/respond"
|
||||
"git.haelnorr.com/h/oslstats/internal/view/seasonsview"
|
||||
)
|
||||
|
||||
@@ -26,6 +27,10 @@ func SeasonAddLeague(
|
||||
if ok := conn.WithNotifyTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
err := db.NewSeasonLeague(ctx, tx, seasonStr, leagueStr, db.NewAudit(r, nil))
|
||||
if err != nil {
|
||||
if db.IsBadRequest(err) {
|
||||
respond.BadRequest(w, err)
|
||||
return false, nil
|
||||
}
|
||||
return false, errors.Wrap(err, "db.NewSeasonLeague")
|
||||
}
|
||||
|
||||
@@ -64,13 +69,17 @@ func SeasonRemoveLeague(
|
||||
var err error
|
||||
season, err = db.GetSeason(ctx, tx, seasonStr)
|
||||
if err != nil {
|
||||
if db.IsBadRequest(err) {
|
||||
respond.NotFound(w, err)
|
||||
return false, nil
|
||||
}
|
||||
return false, errors.Wrap(err, "db.GetSeason")
|
||||
}
|
||||
if season == nil {
|
||||
return false, errors.New("season not found")
|
||||
}
|
||||
err = season.RemoveLeague(ctx, tx, leagueStr, db.NewAudit(r, nil))
|
||||
if err != nil {
|
||||
if db.IsBadRequest(err) {
|
||||
respond.BadRequest(w, err)
|
||||
}
|
||||
return false, errors.Wrap(err, "season.RemoveLeague")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user