~mna/hockeygo

4488f1383ea1eb2f4f7bc9cc9fc053e6eb4c6e99 — Martin Angers 2 years ago 302aa6a
new league args
2 files changed, 42 insertions(+), 9 deletions(-)

M db/migrations/004_leagues.sql
M internal/command/league/league.go
M db/migrations/004_leagues.sql => db/migrations/004_leagues.sql +13 -9
@@ 1,8 1,12 @@
CREATE TABLE leagues (
  id         INT UNSIGNED NOT NULL AUTO_INCREMENT,
  full_name  VARCHAR(100) NOT NULL,
  short_name VARCHAR(5)   NOT NULL,
  created    DATETIME(3)  NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  id                  INT UNSIGNED     NOT NULL AUTO_INCREMENT,
  full_name           VARCHAR(100)     NOT NULL,
  short_name          VARCHAR(5)       NOT NULL,
  home_and_away_count TINYINT UNSIGNED NOT NULL,
  with_playoffs       TINYINT UNSIGNED NOT NULL,
  playoffs_team_count TINYINT UNSIGNED NOT NULL,
  playoffs_best_of    TINYINT UNSIGNED NOT NULL,
  created             DATETIME(3)      NOT NULL DEFAULT CURRENT_TIMESTAMP(3),

  PRIMARY KEY (id),
  UNIQUE INDEX ix_leagues_full_name (full_name),


@@ 10,11 14,11 @@ CREATE TABLE leagues (
);

CREATE TABLE seasons (
  id        INT UNSIGNED     NOT NULL AUTO_INCREMENT,
  league_id INT UNSIGNED     NOT NULL,
  year      TINYINT UNSIGNED NOT NULL,
  completed TINYINT UNSIGNED NOT NULL DEFAULT 0,
  created   DATETIME(3)      NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  id        INT UNSIGNED      NOT NULL AUTO_INCREMENT,
  league_id INT UNSIGNED      NOT NULL,
  year      SMALLINT UNSIGNED NOT NULL,
  completed TINYINT UNSIGNED  NOT NULL DEFAULT 0,
  created   DATETIME(3)       NOT NULL DEFAULT CURRENT_TIMESTAMP(3),

  PRIMARY KEY (id),
  UNIQUE INDEX ix_seasons_league_id_year (league_id, year),

M internal/command/league/league.go => internal/command/league/league.go +29 -0
@@ 7,6 7,35 @@ import (
	"git.sr.ht/~mna/webparts/mainer"
)

type NewLeagueArgs struct {
	FullName         string
	ShortName        string
	StartYear        int
	TeamCount        int
	Teams            []*Team
	HomeAndAwayCount int
	DivisionCount    int
	Divisions        []*Division
	Playoffs         *Playoffs
}

type Team struct {
	City      string
	Name      string
	ShortName string
}

type Division struct {
	Name      string
	ShortName string
	Teams     []string // short names of teams
}

type Playoffs struct {
	TeamCount    int
	BestOfSeries int
}

func Run(ctx context.Context, cmd *command.Cmd, args []string) mainer.ExitCode {
	return mainer.Success
}