Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Francia committed Apr 26, 2024
1 parent 2a3fd33 commit 9f21561
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 121 deletions.
121 changes: 1 addition & 120 deletions internal/data/tournaments.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,126 +226,7 @@ func (m TournamentModel) GetByCode(code string) (*Tournament, error) {

func (m TournamentModel) GetByID(id int) (Tournament, error) {
t := Tournament{}

query := `
SELECT
name,
is_active,
is_verified,
created_at,
updated_at,
updated_by,
deleted_at,
is_deleted,
is_online,
online_link,
is_otb,
is_hybrid,
is_team,
is_individual,
is_rated,
is_unrated,
match_making,
is_private,
is_public,
member_cost,
public_cost,
currency,
is_open,
is_closed,
code,
poster,
dates,
location,
registration_start_date,
registration_end_date,
age_category,
time_control,
type,
rounds,
organizer,
user_organizer,
contact_email,
contact_phone,
country,
province,
city,
address,
postal_code,
observations,
is_cancelled,
players,
teams,
max_attendees,
min_attendees,
completed,
is_draft,
is_published
FROM tournaments
WHERE id = $1`
args := []any{id}

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

err := m.DB.QueryRowContext(ctx, query, args...).Scan(
&t.Name,
&t.IsActive,
&t.IsVerified,
&t.CreatedAt,
&t.UpdatedAt,
&t.UpdatedBy,
&t.DeletedAt,
&t.IsDeleted,
&t.IsOnline,
&t.OnlineLink,
&t.IsOTB,
&t.IsHybrid,
&t.IsTeam,
&t.IsIndividual,
&t.IsRated,
&t.IsUnrated,
&t.MatchMaking,
&t.IsPrivate,
&t.IsPublic,
&t.MemberCost,
&t.PublicCost,
&t.Currency,
&t.IsOpen,
&t.IsClosed,
&t.Code,
&t.Poster,
&t.Dates,
&t.Location,
&t.RegistrationStartDate,
&t.RegistrationEndDate,
&t.AgeCategory,
&t.TimeControl,
&t.Type,
&t.Rounds,
&t.Organizer,
&t.UserOrganizer,
&t.ContactEmail,
&t.ContactPhone,
&t.Country,
&t.Province,
&t.City,
&t.Address,
&t.PostalCode,
&t.Observations,
&t.IsCancelled,
&t.Players,
&t.Teams,
&t.MaxAttendees,
&t.MinAttendees,
&t.Completed,
&t.IsDraft,
&t.IsPublished,
)

if err != nil {
return t, err
}
// query := ``
return t, nil
}

Expand Down
2 changes: 1 addition & 1 deletion migrations/000005_create_tournaments_table.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS tournaments (
observations TEXT NOT NULL DEFAULT '',
is_cancelled BOOLEAN NOT NULL DEFAULT FALSE,

players INTEGER[] NOT NULL DEFAULT '{}', -- user.ids
players INTEGER[] REFERENCES users NOT NULL DEFAULT '{}', -- user.ids
teams INTEGER[] NOT NULL DEFAULT '{}', -- team.ids

max_attendees INTEGER NOT NULL DEFAULT 0,
Expand Down

0 comments on commit 9f21561

Please sign in to comment.