694 lines
17 KiB
Go
694 lines
17 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: events.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const DeleteEvent = `-- name: DeleteEvent :exec
|
|
DELETE FROM events
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteEvent(ctx context.Context, id string) error {
|
|
_, err := q.db.Exec(ctx, DeleteEvent, id)
|
|
return err
|
|
}
|
|
|
|
const GetAllUpcomingEvents = `-- name: GetAllUpcomingEvents :many
|
|
SELECT id,
|
|
sport_id,
|
|
match_name,
|
|
home_team,
|
|
away_team,
|
|
home_team_id,
|
|
away_team_id,
|
|
home_kit_image,
|
|
away_kit_image,
|
|
league_id,
|
|
league_name,
|
|
league_cc,
|
|
start_time,
|
|
is_live,
|
|
status,
|
|
source,
|
|
fetched_at
|
|
FROM events
|
|
WHERE start_time > now()
|
|
AND is_live = false
|
|
AND status = 'upcoming'
|
|
ORDER BY start_time ASC
|
|
`
|
|
|
|
type GetAllUpcomingEventsRow struct {
|
|
ID string `json:"id"`
|
|
SportID pgtype.Int4 `json:"sport_id"`
|
|
MatchName pgtype.Text `json:"match_name"`
|
|
HomeTeam pgtype.Text `json:"home_team"`
|
|
AwayTeam pgtype.Text `json:"away_team"`
|
|
HomeTeamID pgtype.Int4 `json:"home_team_id"`
|
|
AwayTeamID pgtype.Int4 `json:"away_team_id"`
|
|
HomeKitImage pgtype.Text `json:"home_kit_image"`
|
|
AwayKitImage pgtype.Text `json:"away_kit_image"`
|
|
LeagueID pgtype.Int4 `json:"league_id"`
|
|
LeagueName pgtype.Text `json:"league_name"`
|
|
LeagueCc pgtype.Text `json:"league_cc"`
|
|
StartTime pgtype.Timestamp `json:"start_time"`
|
|
IsLive pgtype.Bool `json:"is_live"`
|
|
Status pgtype.Text `json:"status"`
|
|
Source pgtype.Text `json:"source"`
|
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
|
}
|
|
|
|
func (q *Queries) GetAllUpcomingEvents(ctx context.Context) ([]GetAllUpcomingEventsRow, error) {
|
|
rows, err := q.db.Query(ctx, GetAllUpcomingEvents)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetAllUpcomingEventsRow
|
|
for rows.Next() {
|
|
var i GetAllUpcomingEventsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.SportID,
|
|
&i.MatchName,
|
|
&i.HomeTeam,
|
|
&i.AwayTeam,
|
|
&i.HomeTeamID,
|
|
&i.AwayTeamID,
|
|
&i.HomeKitImage,
|
|
&i.AwayKitImage,
|
|
&i.LeagueID,
|
|
&i.LeagueName,
|
|
&i.LeagueCc,
|
|
&i.StartTime,
|
|
&i.IsLive,
|
|
&i.Status,
|
|
&i.Source,
|
|
&i.FetchedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetExpiredUpcomingEvents = `-- name: GetExpiredUpcomingEvents :many
|
|
SELECT events.id,
|
|
events.sport_id,
|
|
events.match_name,
|
|
events.home_team,
|
|
events.away_team,
|
|
events.home_team_id,
|
|
events.away_team_id,
|
|
events.home_kit_image,
|
|
events.away_kit_image,
|
|
events.league_id,
|
|
events.league_name,
|
|
events.start_time,
|
|
events.is_live,
|
|
events.status,
|
|
events.source,
|
|
events.fetched_at,
|
|
leagues.country_code as league_cc
|
|
FROM events
|
|
LEFT JOIN leagues ON leagues.id = league_id
|
|
WHERE start_time < now()
|
|
and (
|
|
status = $1
|
|
OR $1 IS NULL
|
|
)
|
|
ORDER BY start_time ASC
|
|
`
|
|
|
|
type GetExpiredUpcomingEventsRow struct {
|
|
ID string `json:"id"`
|
|
SportID pgtype.Int4 `json:"sport_id"`
|
|
MatchName pgtype.Text `json:"match_name"`
|
|
HomeTeam pgtype.Text `json:"home_team"`
|
|
AwayTeam pgtype.Text `json:"away_team"`
|
|
HomeTeamID pgtype.Int4 `json:"home_team_id"`
|
|
AwayTeamID pgtype.Int4 `json:"away_team_id"`
|
|
HomeKitImage pgtype.Text `json:"home_kit_image"`
|
|
AwayKitImage pgtype.Text `json:"away_kit_image"`
|
|
LeagueID pgtype.Int4 `json:"league_id"`
|
|
LeagueName pgtype.Text `json:"league_name"`
|
|
StartTime pgtype.Timestamp `json:"start_time"`
|
|
IsLive pgtype.Bool `json:"is_live"`
|
|
Status pgtype.Text `json:"status"`
|
|
Source pgtype.Text `json:"source"`
|
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
|
LeagueCc pgtype.Text `json:"league_cc"`
|
|
}
|
|
|
|
func (q *Queries) GetExpiredUpcomingEvents(ctx context.Context, status pgtype.Text) ([]GetExpiredUpcomingEventsRow, error) {
|
|
rows, err := q.db.Query(ctx, GetExpiredUpcomingEvents, status)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetExpiredUpcomingEventsRow
|
|
for rows.Next() {
|
|
var i GetExpiredUpcomingEventsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.SportID,
|
|
&i.MatchName,
|
|
&i.HomeTeam,
|
|
&i.AwayTeam,
|
|
&i.HomeTeamID,
|
|
&i.AwayTeamID,
|
|
&i.HomeKitImage,
|
|
&i.AwayKitImage,
|
|
&i.LeagueID,
|
|
&i.LeagueName,
|
|
&i.StartTime,
|
|
&i.IsLive,
|
|
&i.Status,
|
|
&i.Source,
|
|
&i.FetchedAt,
|
|
&i.LeagueCc,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetPaginatedUpcomingEvents = `-- name: GetPaginatedUpcomingEvents :many
|
|
SELECT events.id,
|
|
events.sport_id,
|
|
events.match_name,
|
|
events.home_team,
|
|
events.away_team,
|
|
events.home_team_id,
|
|
events.away_team_id,
|
|
events.home_kit_image,
|
|
events.away_kit_image,
|
|
events.league_id,
|
|
events.league_name,
|
|
events.start_time,
|
|
events.is_live,
|
|
events.status,
|
|
events.source,
|
|
events.fetched_at,
|
|
leagues.country_code as league_cc
|
|
FROM events
|
|
LEFT JOIN leagues ON leagues.id = league_id
|
|
WHERE start_time > now()
|
|
AND is_live = false
|
|
AND status = 'upcoming'
|
|
AND (
|
|
league_id = $1
|
|
OR $1 IS NULL
|
|
)
|
|
AND (
|
|
events.sport_id = $2
|
|
OR $2 IS NULL
|
|
)
|
|
AND (
|
|
start_time < $3
|
|
OR $3 IS NULL
|
|
)
|
|
AND (
|
|
start_time > $4
|
|
OR $4 IS NULL
|
|
)
|
|
AND (
|
|
leagues.country_code = $5
|
|
OR $5 IS NULL
|
|
)
|
|
ORDER BY start_time ASC
|
|
LIMIT $7 OFFSET $6
|
|
`
|
|
|
|
type GetPaginatedUpcomingEventsParams struct {
|
|
LeagueID pgtype.Int4 `json:"league_id"`
|
|
SportID pgtype.Int4 `json:"sport_id"`
|
|
LastStartTime pgtype.Timestamp `json:"last_start_time"`
|
|
FirstStartTime pgtype.Timestamp `json:"first_start_time"`
|
|
CountryCode pgtype.Text `json:"country_code"`
|
|
Offset pgtype.Int4 `json:"offset"`
|
|
Limit pgtype.Int4 `json:"limit"`
|
|
}
|
|
|
|
type GetPaginatedUpcomingEventsRow struct {
|
|
ID string `json:"id"`
|
|
SportID pgtype.Int4 `json:"sport_id"`
|
|
MatchName pgtype.Text `json:"match_name"`
|
|
HomeTeam pgtype.Text `json:"home_team"`
|
|
AwayTeam pgtype.Text `json:"away_team"`
|
|
HomeTeamID pgtype.Int4 `json:"home_team_id"`
|
|
AwayTeamID pgtype.Int4 `json:"away_team_id"`
|
|
HomeKitImage pgtype.Text `json:"home_kit_image"`
|
|
AwayKitImage pgtype.Text `json:"away_kit_image"`
|
|
LeagueID pgtype.Int4 `json:"league_id"`
|
|
LeagueName pgtype.Text `json:"league_name"`
|
|
StartTime pgtype.Timestamp `json:"start_time"`
|
|
IsLive pgtype.Bool `json:"is_live"`
|
|
Status pgtype.Text `json:"status"`
|
|
Source pgtype.Text `json:"source"`
|
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
|
LeagueCc pgtype.Text `json:"league_cc"`
|
|
}
|
|
|
|
func (q *Queries) GetPaginatedUpcomingEvents(ctx context.Context, arg GetPaginatedUpcomingEventsParams) ([]GetPaginatedUpcomingEventsRow, error) {
|
|
rows, err := q.db.Query(ctx, GetPaginatedUpcomingEvents,
|
|
arg.LeagueID,
|
|
arg.SportID,
|
|
arg.LastStartTime,
|
|
arg.FirstStartTime,
|
|
arg.CountryCode,
|
|
arg.Offset,
|
|
arg.Limit,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetPaginatedUpcomingEventsRow
|
|
for rows.Next() {
|
|
var i GetPaginatedUpcomingEventsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.SportID,
|
|
&i.MatchName,
|
|
&i.HomeTeam,
|
|
&i.AwayTeam,
|
|
&i.HomeTeamID,
|
|
&i.AwayTeamID,
|
|
&i.HomeKitImage,
|
|
&i.AwayKitImage,
|
|
&i.LeagueID,
|
|
&i.LeagueName,
|
|
&i.StartTime,
|
|
&i.IsLive,
|
|
&i.Status,
|
|
&i.Source,
|
|
&i.FetchedAt,
|
|
&i.LeagueCc,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetTotalEvents = `-- name: GetTotalEvents :one
|
|
SELECT COUNT(*)
|
|
FROM events
|
|
LEFT JOIN leagues ON leagues.id = league_id
|
|
WHERE is_live = false
|
|
AND status = 'upcoming'
|
|
AND (
|
|
league_id = $1
|
|
OR $1 IS NULL
|
|
)
|
|
AND (
|
|
events.sport_id = $2
|
|
OR $2 IS NULL
|
|
)
|
|
AND (
|
|
start_time < $3
|
|
OR $3 IS NULL
|
|
)
|
|
AND (
|
|
start_time > $4
|
|
OR $4 IS NULL
|
|
)
|
|
AND (
|
|
leagues.country_code = $5
|
|
OR $5 IS NULL
|
|
)
|
|
`
|
|
|
|
type GetTotalEventsParams struct {
|
|
LeagueID pgtype.Int4 `json:"league_id"`
|
|
SportID pgtype.Int4 `json:"sport_id"`
|
|
LastStartTime pgtype.Timestamp `json:"last_start_time"`
|
|
FirstStartTime pgtype.Timestamp `json:"first_start_time"`
|
|
CountryCode pgtype.Text `json:"country_code"`
|
|
}
|
|
|
|
func (q *Queries) GetTotalEvents(ctx context.Context, arg GetTotalEventsParams) (int64, error) {
|
|
row := q.db.QueryRow(ctx, GetTotalEvents,
|
|
arg.LeagueID,
|
|
arg.SportID,
|
|
arg.LastStartTime,
|
|
arg.FirstStartTime,
|
|
arg.CountryCode,
|
|
)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const GetUpcomingByID = `-- name: GetUpcomingByID :one
|
|
SELECT id,
|
|
sport_id,
|
|
match_name,
|
|
home_team,
|
|
away_team,
|
|
home_team_id,
|
|
away_team_id,
|
|
home_kit_image,
|
|
away_kit_image,
|
|
league_id,
|
|
league_name,
|
|
league_cc,
|
|
start_time,
|
|
is_live,
|
|
status,
|
|
source,
|
|
fetched_at
|
|
FROM events
|
|
WHERE id = $1
|
|
AND is_live = false
|
|
AND status = 'upcoming'
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetUpcomingByIDRow struct {
|
|
ID string `json:"id"`
|
|
SportID pgtype.Int4 `json:"sport_id"`
|
|
MatchName pgtype.Text `json:"match_name"`
|
|
HomeTeam pgtype.Text `json:"home_team"`
|
|
AwayTeam pgtype.Text `json:"away_team"`
|
|
HomeTeamID pgtype.Int4 `json:"home_team_id"`
|
|
AwayTeamID pgtype.Int4 `json:"away_team_id"`
|
|
HomeKitImage pgtype.Text `json:"home_kit_image"`
|
|
AwayKitImage pgtype.Text `json:"away_kit_image"`
|
|
LeagueID pgtype.Int4 `json:"league_id"`
|
|
LeagueName pgtype.Text `json:"league_name"`
|
|
LeagueCc pgtype.Text `json:"league_cc"`
|
|
StartTime pgtype.Timestamp `json:"start_time"`
|
|
IsLive pgtype.Bool `json:"is_live"`
|
|
Status pgtype.Text `json:"status"`
|
|
Source pgtype.Text `json:"source"`
|
|
FetchedAt pgtype.Timestamp `json:"fetched_at"`
|
|
}
|
|
|
|
func (q *Queries) GetUpcomingByID(ctx context.Context, id string) (GetUpcomingByIDRow, error) {
|
|
row := q.db.QueryRow(ctx, GetUpcomingByID, id)
|
|
var i GetUpcomingByIDRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.SportID,
|
|
&i.MatchName,
|
|
&i.HomeTeam,
|
|
&i.AwayTeam,
|
|
&i.HomeTeamID,
|
|
&i.AwayTeamID,
|
|
&i.HomeKitImage,
|
|
&i.AwayKitImage,
|
|
&i.LeagueID,
|
|
&i.LeagueName,
|
|
&i.LeagueCc,
|
|
&i.StartTime,
|
|
&i.IsLive,
|
|
&i.Status,
|
|
&i.Source,
|
|
&i.FetchedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const InsertEvent = `-- name: InsertEvent :exec
|
|
INSERT INTO events (
|
|
id,
|
|
sport_id,
|
|
match_name,
|
|
home_team,
|
|
away_team,
|
|
home_team_id,
|
|
away_team_id,
|
|
home_kit_image,
|
|
away_kit_image,
|
|
league_id,
|
|
league_name,
|
|
league_cc,
|
|
start_time,
|
|
score,
|
|
match_minute,
|
|
timer_status,
|
|
added_time,
|
|
match_period,
|
|
is_live,
|
|
status,
|
|
source
|
|
)
|
|
VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7,
|
|
$8,
|
|
$9,
|
|
$10,
|
|
$11,
|
|
$12,
|
|
$13,
|
|
$14,
|
|
$15,
|
|
$16,
|
|
$17,
|
|
$18,
|
|
$19,
|
|
$20,
|
|
$21
|
|
) ON CONFLICT (id) DO
|
|
UPDATE
|
|
SET sport_id = EXCLUDED.sport_id,
|
|
match_name = EXCLUDED.match_name,
|
|
home_team = EXCLUDED.home_team,
|
|
away_team = EXCLUDED.away_team,
|
|
home_team_id = EXCLUDED.home_team_id,
|
|
away_team_id = EXCLUDED.away_team_id,
|
|
home_kit_image = EXCLUDED.home_kit_image,
|
|
away_kit_image = EXCLUDED.away_kit_image,
|
|
league_id = EXCLUDED.league_id,
|
|
league_name = EXCLUDED.league_name,
|
|
league_cc = EXCLUDED.league_cc,
|
|
start_time = EXCLUDED.start_time,
|
|
score = EXCLUDED.score,
|
|
match_minute = EXCLUDED.match_minute,
|
|
timer_status = EXCLUDED.timer_status,
|
|
added_time = EXCLUDED.added_time,
|
|
match_period = EXCLUDED.match_period,
|
|
is_live = EXCLUDED.is_live,
|
|
status = EXCLUDED.status,
|
|
source = EXCLUDED.source,
|
|
fetched_at = now()
|
|
`
|
|
|
|
type InsertEventParams struct {
|
|
ID string `json:"id"`
|
|
SportID pgtype.Int4 `json:"sport_id"`
|
|
MatchName pgtype.Text `json:"match_name"`
|
|
HomeTeam pgtype.Text `json:"home_team"`
|
|
AwayTeam pgtype.Text `json:"away_team"`
|
|
HomeTeamID pgtype.Int4 `json:"home_team_id"`
|
|
AwayTeamID pgtype.Int4 `json:"away_team_id"`
|
|
HomeKitImage pgtype.Text `json:"home_kit_image"`
|
|
AwayKitImage pgtype.Text `json:"away_kit_image"`
|
|
LeagueID pgtype.Int4 `json:"league_id"`
|
|
LeagueName pgtype.Text `json:"league_name"`
|
|
LeagueCc pgtype.Text `json:"league_cc"`
|
|
StartTime pgtype.Timestamp `json:"start_time"`
|
|
Score pgtype.Text `json:"score"`
|
|
MatchMinute pgtype.Int4 `json:"match_minute"`
|
|
TimerStatus pgtype.Text `json:"timer_status"`
|
|
AddedTime pgtype.Int4 `json:"added_time"`
|
|
MatchPeriod pgtype.Int4 `json:"match_period"`
|
|
IsLive pgtype.Bool `json:"is_live"`
|
|
Status pgtype.Text `json:"status"`
|
|
Source pgtype.Text `json:"source"`
|
|
}
|
|
|
|
func (q *Queries) InsertEvent(ctx context.Context, arg InsertEventParams) error {
|
|
_, err := q.db.Exec(ctx, InsertEvent,
|
|
arg.ID,
|
|
arg.SportID,
|
|
arg.MatchName,
|
|
arg.HomeTeam,
|
|
arg.AwayTeam,
|
|
arg.HomeTeamID,
|
|
arg.AwayTeamID,
|
|
arg.HomeKitImage,
|
|
arg.AwayKitImage,
|
|
arg.LeagueID,
|
|
arg.LeagueName,
|
|
arg.LeagueCc,
|
|
arg.StartTime,
|
|
arg.Score,
|
|
arg.MatchMinute,
|
|
arg.TimerStatus,
|
|
arg.AddedTime,
|
|
arg.MatchPeriod,
|
|
arg.IsLive,
|
|
arg.Status,
|
|
arg.Source,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const InsertUpcomingEvent = `-- name: InsertUpcomingEvent :exec
|
|
INSERT INTO events (
|
|
id,
|
|
sport_id,
|
|
match_name,
|
|
home_team,
|
|
away_team,
|
|
home_team_id,
|
|
away_team_id,
|
|
home_kit_image,
|
|
away_kit_image,
|
|
league_id,
|
|
league_name,
|
|
league_cc,
|
|
start_time,
|
|
is_live,
|
|
status,
|
|
source
|
|
)
|
|
VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7,
|
|
$8,
|
|
$9,
|
|
$10,
|
|
$11,
|
|
$12,
|
|
$13,
|
|
false,
|
|
'upcoming',
|
|
$14
|
|
) ON CONFLICT (id) DO
|
|
UPDATE
|
|
SET sport_id = EXCLUDED.sport_id,
|
|
match_name = EXCLUDED.match_name,
|
|
home_team = EXCLUDED.home_team,
|
|
away_team = EXCLUDED.away_team,
|
|
home_team_id = EXCLUDED.home_team_id,
|
|
away_team_id = EXCLUDED.away_team_id,
|
|
home_kit_image = EXCLUDED.home_kit_image,
|
|
away_kit_image = EXCLUDED.away_kit_image,
|
|
league_id = EXCLUDED.league_id,
|
|
league_name = EXCLUDED.league_name,
|
|
league_cc = EXCLUDED.league_cc,
|
|
start_time = EXCLUDED.start_time,
|
|
is_live = false,
|
|
status = 'upcoming',
|
|
source = EXCLUDED.source,
|
|
fetched_at = now()
|
|
`
|
|
|
|
type InsertUpcomingEventParams struct {
|
|
ID string `json:"id"`
|
|
SportID pgtype.Int4 `json:"sport_id"`
|
|
MatchName pgtype.Text `json:"match_name"`
|
|
HomeTeam pgtype.Text `json:"home_team"`
|
|
AwayTeam pgtype.Text `json:"away_team"`
|
|
HomeTeamID pgtype.Int4 `json:"home_team_id"`
|
|
AwayTeamID pgtype.Int4 `json:"away_team_id"`
|
|
HomeKitImage pgtype.Text `json:"home_kit_image"`
|
|
AwayKitImage pgtype.Text `json:"away_kit_image"`
|
|
LeagueID pgtype.Int4 `json:"league_id"`
|
|
LeagueName pgtype.Text `json:"league_name"`
|
|
LeagueCc pgtype.Text `json:"league_cc"`
|
|
StartTime pgtype.Timestamp `json:"start_time"`
|
|
Source pgtype.Text `json:"source"`
|
|
}
|
|
|
|
func (q *Queries) InsertUpcomingEvent(ctx context.Context, arg InsertUpcomingEventParams) error {
|
|
_, err := q.db.Exec(ctx, InsertUpcomingEvent,
|
|
arg.ID,
|
|
arg.SportID,
|
|
arg.MatchName,
|
|
arg.HomeTeam,
|
|
arg.AwayTeam,
|
|
arg.HomeTeamID,
|
|
arg.AwayTeamID,
|
|
arg.HomeKitImage,
|
|
arg.AwayKitImage,
|
|
arg.LeagueID,
|
|
arg.LeagueName,
|
|
arg.LeagueCc,
|
|
arg.StartTime,
|
|
arg.Source,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const ListLiveEvents = `-- name: ListLiveEvents :many
|
|
SELECT id
|
|
FROM events
|
|
WHERE is_live = true
|
|
`
|
|
|
|
func (q *Queries) ListLiveEvents(ctx context.Context) ([]string, error) {
|
|
rows, err := q.db.Query(ctx, ListLiveEvents)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []string
|
|
for rows.Next() {
|
|
var id string
|
|
if err := rows.Scan(&id); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, id)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const UpdateMatchResult = `-- name: UpdateMatchResult :exec
|
|
UPDATE events
|
|
SET score = $1,
|
|
status = $2,
|
|
fetched_at = NOW()
|
|
WHERE id = $3
|
|
`
|
|
|
|
type UpdateMatchResultParams struct {
|
|
Score pgtype.Text `json:"score"`
|
|
Status pgtype.Text `json:"status"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateMatchResult(ctx context.Context, arg UpdateMatchResultParams) error {
|
|
_, err := q.db.Exec(ctx, UpdateMatchResult, arg.Score, arg.Status, arg.ID)
|
|
return err
|
|
}
|