everybody loves a refactor
This commit is contained in:
@@ -22,12 +22,15 @@ func SeasonLeaguePage(
|
||||
leagueStr := r.PathValue("league_short_name")
|
||||
|
||||
var season *db.Season
|
||||
var league *db.League
|
||||
|
||||
if ok := conn.WithReadTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
|
||||
var err error
|
||||
season, league, _, err = db.GetSeasonLeague(ctx, tx, seasonStr, leagueStr)
|
||||
season, _, _, err = db.GetSeasonLeague(ctx, tx, seasonStr, leagueStr)
|
||||
if err != nil {
|
||||
if db.IsBadRequest(err) {
|
||||
throw.NotFound(s, w, r, r.URL.Path)
|
||||
return false, nil
|
||||
}
|
||||
return false, errors.Wrap(err, "db.GetSeasonLeague")
|
||||
}
|
||||
return true, nil
|
||||
@@ -35,11 +38,6 @@ func SeasonLeaguePage(
|
||||
return
|
||||
}
|
||||
|
||||
if season == nil || league == nil {
|
||||
throw.NotFound(s, w, r, r.URL.Path)
|
||||
return
|
||||
}
|
||||
|
||||
defaultTab := season.GetDefaultTab()
|
||||
redirectURL := fmt.Sprintf(
|
||||
"/seasons/%s/leagues/%s/%s",
|
||||
|
||||
Reference in New Issue
Block a user