package teamsview import "git.haelnorr.com/h/oslstats/internal/db" import "git.haelnorr.com/h/oslstats/internal/view/seasonsview" import "fmt" templ TeamDetailSeasons(team *db.Team, seasonInfos []*db.TeamSeasonInfo) { if len(seasonInfos) == 0 {

No season history yet.

This team has not participated in any seasons.

} else {
for _, info := range seasonInfos { @teamSeasonCard(team, info) }
} } templ teamSeasonCard(team *db.Team, info *db.TeamSeasonInfo) { {{ detailURL := fmt.Sprintf( "/seasons/%s/leagues/%s/teams/%d", info.Season.ShortName, info.League.ShortName, team.ID, ) }}

{ info.Season.Name }

{ info.League.Name }
@seasonsview.StatusBadge(info.Season, true, true)
Position { ordinal(info.Position) } / { fmt.Sprint(info.TotalTeams) }
Points

{ fmt.Sprint(info.Record.Points) }

W

{ fmt.Sprint(info.Record.Wins) }

OTW

{ fmt.Sprint(info.Record.OvertimeWins) }

OTL

{ fmt.Sprint(info.Record.OvertimeLosses) }

L

{ fmt.Sprint(info.Record.Losses) }

} func ordinal(n int) string { suffix := "th" if n%100 >= 11 && n%100 <= 13 { // 11th, 12th, 13th } else { switch n % 10 { case 1: suffix = "st" case 2: suffix = "nd" case 3: suffix = "rd" } } return fmt.Sprintf("%d%s", n, suffix) }