db

package
v0.0.0-...-481979b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Competition

type Competition struct {
	// Unique identifier for each competition
	ID int64
	// Name of the competition (e.g., NRL, NRLW)
	Name string
	// Indicates the current round or game for the competition (e.g., Round 1 for NRL, Game 1 for State of Origin)
	Round *string
}

type CreateFixtureParams

type CreateFixtureParams struct {
	ID             int64
	CompetitionID  int64
	Roundtitle     string
	Matchstate     string
	Venue          string
	Venuecity      string
	Matchcentreurl string
	Kickofftime    pgtype.Timestamp
}

type CreateMatchDetailParams

type CreateMatchDetailParams struct {
	FixtureID     int64
	HometeamID    int64
	AwayteamID    int64
	HometeamOdds  *float64
	AwayteamOdds  *float64
	HometeamScore *int32
	AwayteamScore *int32
	HometeamForm  string
	AwayteamForm  string
	WinnerTeamid  *int64
}

type CreateTeamParams

type CreateTeamParams struct {
	ID            int64
	Nickname      string
	CompetitionID int64
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type Fixture

type Fixture struct {
	// Unique identifier for each fixture
	ID int64
	// Foreign key referencing competitions table
	CompetitionID int64
	// Title of the round (e.g., Round 1)
	Roundtitle string
	// Current state of the match (e.g., Upcoming, Completed)
	Matchstate string
	// Venue name where the match will take place
	Venue string
	// City where the venue is located
	Venuecity string
	// URL to the match center page
	Matchcentreurl string
	// Scheduled kickoff time of the match
	Kickofftime pgtype.Timestamp
}

type GetMatchDetailsByFixtureIDRow

type GetMatchDetailsByFixtureIDRow struct {
	MatchDetail MatchDetail
	Fixture     Fixture
	Team        Team
	Team_2      Team
}

type ListCurrentRoundMatchDetailsByCompetitionIDRow

type ListCurrentRoundMatchDetailsByCompetitionIDRow struct {
	MatchDetail MatchDetail
	Fixture     Fixture
	Team        Team
	Team_2      Team
}

type ListMatchDetailsByCompetitionIDRow

type ListMatchDetailsByCompetitionIDRow struct {
	MatchDetail MatchDetail
	Fixture     Fixture
	Team        Team
	Team_2      Team
}

type ListMatchDetailsRow

type ListMatchDetailsRow struct {
	MatchDetail MatchDetail
	Fixture     Fixture
	Team        Team
	Team_2      Team
}

type ListRoundMatchDetailsByCompetitionIDParams

type ListRoundMatchDetailsByCompetitionIDParams struct {
	CompetitionID int64
	Roundtitle    string
}

type ListRoundMatchDetailsByCompetitionIDRow

type ListRoundMatchDetailsByCompetitionIDRow struct {
	MatchDetail MatchDetail
	Fixture     Fixture
	Team        Team
	Team_2      Team
}

type MatchDetail

type MatchDetail struct {
	// Foreign key referencing fixtures table
	FixtureID int64
	// Foreign key for home team referencing teams table
	HometeamID int64
	// Foreign key for away team referencing teams table
	AwayteamID int64
	// Odds for the home team winning
	HometeamOdds *float64
	// Odds for the away team winning
	AwayteamOdds *float64
	// Score of the home team
	HometeamScore *int32
	// Score of the away team
	AwayteamScore *int32
	// Recent form of the home team (e.g., WLWWL)
	HometeamForm string
	// Recent form of the away team (e.g., LWWLL)
	AwayteamForm string
	// Foreign key referencing the winning team
	WinnerTeamid *int64
}

type Querier

type Querier interface {
	// Insert a new fixture into the fixtures table.
	// This query adds a new fixture record with the specified details, such as
	// competition ID, round title, match state, venue, venue city, match center URL,
	// and kickoff time.
	CreateFixture(ctx context.Context, arg CreateFixtureParams) (*Fixture, error)
	// Insert a new match detail record into the match_details table.
	// If a match detail with the same fixture_id already exists, do nothing.
	CreateMatchDetail(ctx context.Context, arg CreateMatchDetailParams) (*MatchDetail, error)
	// Insert a new team into the teams table.
	// If a team with the same team_id already exists, do nothing.
	CreateTeam(ctx context.Context, arg CreateTeamParams) (*Team, error)
	// Retrieve a specific competition by its unique identifier.
	GetCompetitionByID(ctx context.Context, id int64) (*Competition, error)
	// Retrieve a specific fixture by its unique identifier.
	// Useful for fetching details about a single fixture based on its ID.
	GetFixtureByID(ctx context.Context, id int64) (*Fixture, error)
	// Retrieve fixtures for a specific competition, ordered by kickoff time.
	// This query fetches all fixtures for a given competition ID, ordered by their
	// kickoff time to display them in chronological order.
	GetFixturesByCompetitionID(ctx context.Context, competitionID int64) ([]*Fixture, error)
	// Retrieve match details for a specific fixture by its unique fixture ID.
	GetMatchDetailsByFixtureID(ctx context.Context, fixtureID int64) (*GetMatchDetailsByFixtureIDRow, error)
	// Retrieve a specific team by its unique identifier.
	GetTeamByID(ctx context.Context, id int64) (*Team, error)
	// The competitions table is a static table that stores information about the
	// competitions that are available in the system. Other tables in the system
	// reference this table to establish a relationship.
	// Retrieve all competitions available in the system.
	ListCompetitions(ctx context.Context) ([]*Competition, error)
	// Retrieve all match details for a specific competition ID.
	// This query performs a JOIN between match_details and fixtures to get all
	// match details that are part of a specific competition and round.
	ListCurrentRoundMatchDetailsByCompetitionID(ctx context.Context, id int64) ([]*ListCurrentRoundMatchDetailsByCompetitionIDRow, error)
	// Retrieve all fixtures available in the system.
	// This query is used to list all fixtures without filtering by any criteria.
	ListFixtures(ctx context.Context) ([]*Fixture, error)
	// Retrieve all match details available in the system.
	ListMatchDetails(ctx context.Context) ([]*ListMatchDetailsRow, error)
	// Retrieve all match details for a specific competition ID.
	// This query performs a JOIN between match_details and fixtures to get all
	// match details that are part of a specific competition.
	ListMatchDetailsByCompetitionID(ctx context.Context, competitionID int64) ([]*ListMatchDetailsByCompetitionIDRow, error)
	// Retrieve all match details for a specific competition ID.
	// This query performs a JOIN between match_details and fixtures to get all
	// match details that are part of a specific competition and round.
	ListRoundMatchDetailsByCompetitionID(ctx context.Context, arg ListRoundMatchDetailsByCompetitionIDParams) ([]*ListRoundMatchDetailsByCompetitionIDRow, error)
	// Retrieve all teams available in the system.
	ListTeams(ctx context.Context) ([]*Team, error)
	// The following commands for creating, updating, and deleting competitions
	// are not required since this is a static table with fixed records:
	// - NRL (111)
	// - NRLW (161)
	// - State of Origin (116)
	// - State of Origin Womens (156)
	//
	// However, if future updates to this table are needed (e.g., new competitions),
	// you may add additional commands to handle such changes.
	// Update the current round for a competition.
	// This query updates the round field for a specific competition based on the
	// provided competition ID.
	UpdateCompetitionRound(ctx context.Context, arg UpdateCompetitionRoundParams) (*Competition, error)
	// Conditionally update fixture details based on provided arguments.
	// This query updates the fields of a fixture record where the provided arguments
	// are not NULL. It uses the COALESCE function to retain the existing value if
	// the argument is NULL.
	UpdateFixture(ctx context.Context, arg UpdateFixtureParams) (*Fixture, error)
	// Conditionally update match detail fields based on provided arguments.
	// Only updates fields where the argument is not NULL.
	UpdateMatchDetail(ctx context.Context, arg UpdateMatchDetailParams) (*MatchDetail, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CreateFixture

func (q *Queries) CreateFixture(ctx context.Context, arg CreateFixtureParams) (*Fixture, error)

Insert a new fixture into the fixtures table. This query adds a new fixture record with the specified details, such as competition ID, round title, match state, venue, venue city, match center URL, and kickoff time.

func (*Queries) CreateMatchDetail

func (q *Queries) CreateMatchDetail(ctx context.Context, arg CreateMatchDetailParams) (*MatchDetail, error)

Insert a new match detail record into the match_details table. If a match detail with the same fixture_id already exists, do nothing.

func (*Queries) CreateTeam

func (q *Queries) CreateTeam(ctx context.Context, arg CreateTeamParams) (*Team, error)

Insert a new team into the teams table. If a team with the same team_id already exists, do nothing.

func (*Queries) GetCompetitionByID

func (q *Queries) GetCompetitionByID(ctx context.Context, id int64) (*Competition, error)

Retrieve a specific competition by its unique identifier.

func (*Queries) GetFixtureByID

func (q *Queries) GetFixtureByID(ctx context.Context, id int64) (*Fixture, error)

Retrieve a specific fixture by its unique identifier. Useful for fetching details about a single fixture based on its ID.

func (*Queries) GetFixturesByCompetitionID

func (q *Queries) GetFixturesByCompetitionID(ctx context.Context, competitionID int64) ([]*Fixture, error)

Retrieve fixtures for a specific competition, ordered by kickoff time. This query fetches all fixtures for a given competition ID, ordered by their kickoff time to display them in chronological order.

func (*Queries) GetMatchDetailsByFixtureID

func (q *Queries) GetMatchDetailsByFixtureID(ctx context.Context, fixtureID int64) (*GetMatchDetailsByFixtureIDRow, error)

Retrieve match details for a specific fixture by its unique fixture ID.

func (*Queries) GetTeamByID

func (q *Queries) GetTeamByID(ctx context.Context, id int64) (*Team, error)

Retrieve a specific team by its unique identifier.

func (*Queries) ListCompetitions

func (q *Queries) ListCompetitions(ctx context.Context) ([]*Competition, error)

The competitions table is a static table that stores information about the competitions that are available in the system. Other tables in the system reference this table to establish a relationship. Retrieve all competitions available in the system.

func (*Queries) ListCurrentRoundMatchDetailsByCompetitionID

func (q *Queries) ListCurrentRoundMatchDetailsByCompetitionID(ctx context.Context, id int64) ([]*ListCurrentRoundMatchDetailsByCompetitionIDRow, error)

Retrieve all match details for a specific competition ID. This query performs a JOIN between match_details and fixtures to get all match details that are part of a specific competition and round.

func (*Queries) ListFixtures

func (q *Queries) ListFixtures(ctx context.Context) ([]*Fixture, error)

Retrieve all fixtures available in the system. This query is used to list all fixtures without filtering by any criteria.

func (*Queries) ListMatchDetails

func (q *Queries) ListMatchDetails(ctx context.Context) ([]*ListMatchDetailsRow, error)

Retrieve all match details available in the system.

func (*Queries) ListMatchDetailsByCompetitionID

func (q *Queries) ListMatchDetailsByCompetitionID(ctx context.Context, competitionID int64) ([]*ListMatchDetailsByCompetitionIDRow, error)

Retrieve all match details for a specific competition ID. This query performs a JOIN between match_details and fixtures to get all match details that are part of a specific competition.

func (*Queries) ListRoundMatchDetailsByCompetitionID

Retrieve all match details for a specific competition ID. This query performs a JOIN between match_details and fixtures to get all match details that are part of a specific competition and round.

func (*Queries) ListTeams

func (q *Queries) ListTeams(ctx context.Context) ([]*Team, error)

Retrieve all teams available in the system.

func (*Queries) UpdateCompetitionRound

func (q *Queries) UpdateCompetitionRound(ctx context.Context, arg UpdateCompetitionRoundParams) (*Competition, error)

The following commands for creating, updating, and deleting competitions are not required since this is a static table with fixed records: - NRL (111) - NRLW (161) - State of Origin (116) - State of Origin Womens (156)

However, if future updates to this table are needed (e.g., new competitions), you may add additional commands to handle such changes. Update the current round for a competition. This query updates the round field for a specific competition based on the provided competition ID.

func (*Queries) UpdateFixture

func (q *Queries) UpdateFixture(ctx context.Context, arg UpdateFixtureParams) (*Fixture, error)

Conditionally update fixture details based on provided arguments. This query updates the fields of a fixture record where the provided arguments are not NULL. It uses the COALESCE function to retain the existing value if the argument is NULL.

func (*Queries) UpdateMatchDetail

func (q *Queries) UpdateMatchDetail(ctx context.Context, arg UpdateMatchDetailParams) (*MatchDetail, error)

Conditionally update match detail fields based on provided arguments. Only updates fields where the argument is not NULL.

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Team

type Team struct {
	// Unique identifier for each team
	ID int64
	// Nickname or short name for the team (e.g., Cowboys)
	Nickname      string
	CompetitionID int64
}

type UpdateCompetitionRoundParams

type UpdateCompetitionRoundParams struct {
	ID    int64
	Round *string
}

type UpdateFixtureParams

type UpdateFixtureParams struct {
	ID         int64
	MatchState *string
}

type UpdateMatchDetailParams

type UpdateMatchDetailParams struct {
	FixtureID     int64
	HomeTeamOdds  *float64
	AwayTeamOdds  *float64
	HomeTeamScore *int32
	AwayTeamScore *int32
	WinnerTeamId  *int64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL