package models

import "time"

type Contest struct {
	Id        int32     `db:"id"`
	Title     string    `db:"title"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type ContestsListItem struct {
	Id        int32     `db:"id"`
	Title     string    `db:"title"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type ContestsList struct {
	Contests   []*ContestsListItem
	Pagination Pagination
}

type ContestsFilter struct {
	Page     int32
	PageSize int32
}

func (f ContestsFilter) Offset() int32 {
	return (f.Page - 1) * f.PageSize
}

type ContestUpdate struct {
	Title *string `json:"title"`
}

type Monitor struct {
	Participants []*ParticipantsStat
	Summary      []*ProblemStatSummary
}

type ParticipantsStat struct {
	Id             int32                `db:"id"`
	Name           string               `db:"name"`
	SolvedInTotal  int32                `db:"solved_in_total"`
	PenaltyInTotal int32                `db:"penalty_in_total"`
	Solutions      []*SolutionsListItem `db:"solutions"`
}

type ProblemStatSummary struct {
	Id       int32 `db:"task_id"`
	Position int32 `db:"position"`
	Success  int32 `db:"success"`
	Total    int32 `db:"total"`
}