tournaments

package
Version: v0.1.31-0...-b1e5c7a Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: ISC Imports: 17 Imported by: 0

Documentation

Overview

Package tournaments provides the JSON handlers to handle tournaments data in gonawin app.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivatePhase

func ActivatePhase(w http.ResponseWriter, r *http.Request, u *mdl.User) error

ActivatePhase handler let you activate phase of tournament.

Use this handler to activate all the matches of given phase in tournament.

GET	/j/tournaments/[0-9]+/admin/activatephase/

func AddAdmin

func AddAdmin(w http.ResponseWriter, r *http.Request, u *mdl.User) error

AddAdmin let you add an admin to a tournament.

GET	/j/tournaments/[0-9]+/admin/add/

func BlockMatchPrediction

func BlockMatchPrediction(w http.ResponseWriter, r *http.Request, u *mdl.User) error

BlockMatchPrediction is the handler allowing to block the prediction for match of tournament.

func Calendar

func Calendar(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Calendar handler gets you the calendar data of a specific tournament. Use this handler to get the calendar of a tournament. The calendar structure is an array of the tournament matches with the following information: * the location * the teams involved * the date by default the data returned is grouped by days.This means we will return an array of days, each of which can have an array of matches. You can also specify the 'groupby' parameter to be 'day' or 'phase' in which case you would have an array of phases, each of which would have an array of days who would have an array of matches.

func CalendarWithPrediction

func CalendarWithPrediction(w http.ResponseWriter, r *http.Request, u *mdl.User) error

CalendarWithPrediction handler give you a JSON tournament calendar with the user predictions. Use this handler to get the calendar of a tournament with the predictions of the players in a specific team. The calendar structure is an array of the tournament matches with the following information: * the location * the teams involved * the date by default the data returned is grouped by days.This means we will return an array of days, each of which can have an array of matches. the 'groupby' parameter does not support 'phases' yet.

func CandidateTeams

func CandidateTeams(w http.ResponseWriter, r *http.Request, u *mdl.User) error

CandidateTeams handler, use it to get the list of teams that you can add to a tournament.

func Destroy

func Destroy(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Destroy is the handler allowing to detroy a tournament.

func GetChampionsLeague

func GetChampionsLeague(w http.ResponseWriter, r *http.Request, u *mdl.User) error

GetChampionsLeague returns the json data of the champions league tournament.

func GetCopaAmerica

func GetCopaAmerica(w http.ResponseWriter, r *http.Request, u *mdl.User) error

GetCopaAmerica returns the json data of the current Copa America tournament.

func GetEuro

func GetEuro(w http.ResponseWriter, r *http.Request, u *mdl.User) error

GetEuro returns the json data of the Euro tournament.

func GetWorldCup

func GetWorldCup(w http.ResponseWriter, r *http.Request, u *mdl.User) error

GetWorldCup is the get world cup tournament handler.

func Groups

func Groups(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Groups handelr sends the JSON tournament groups data. use this handler to get groups of a tournament.

func Index

func Index(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Index handler, use it to get the data of current tournaments.

func Join

func Join(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Join handler let the user join a tournament.

POST	/j/tournaments/join/:tournamentId	let a user join a tournament.

func JoinAsTeam

func JoinAsTeam(w http.ResponseWriter, r *http.Request, u *mdl.User) error

JoinAsTeam makes all members of a team join the tournament.

POST	j/tournaments/joinasteam/:tournamentId/:teamId	let a team join a tournament.

func LeaveAsTeam

func LeaveAsTeam(w http.ResponseWriter, r *http.Request, u *mdl.User) error

LeaveAsTeam makes the team leave the tournament.

func Matches

func Matches(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Matches is the handler allowing to get the matches of a tournament. use the filter parameter to specify the matches you want: if filter is equal to 'first' you wil get matches of the first phase of the tournament. if filter is equal to 'second' you will get the matches of the second phase of the tournament.

func New

func New(w http.ResponseWriter, r *http.Request, u *mdl.User) error

New handler, use it to create a new tournament.

func NewChampionsLeague

func NewChampionsLeague(w http.ResponseWriter, r *http.Request, u *mdl.User) error

NewChampionsLeague creates a champions league tournament.

func NewCopaAmerica

func NewCopaAmerica(w http.ResponseWriter, r *http.Request, u *mdl.User) error

NewCopaAmerica creates a the current copa america tournament.

func NewEuro

func NewEuro(w http.ResponseWriter, r *http.Request, u *mdl.User) error

NewEuro creates a euro tournament.

func NewWorldCup

func NewWorldCup(w http.ResponseWriter, r *http.Request, u *mdl.User) error

NewWorldCup is the new world cup tournament handler.

func Participants

func Participants(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Participants handler, use it to get the participants to a tournament. use this handler to get participants of a tournament.

func Predict

func Predict(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Predict handler, use it to set the predictions of a match to the current user.

func Ranking

func Ranking(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Ranking is the Tournament ranking handler: Use this handler to get the ranking of a tournament. The ranking is an array of users (members) or teams, You can specify the rankby parameter to be "users" or "teams".

GET	/j/tournament/[0-9]+/ranking/

The response is an array of users.

func RemoveAdmin

func RemoveAdmin(w http.ResponseWriter, r *http.Request, u *mdl.User) error

RemoveAdmin handler lets you remove an admin from a tournament.

Use this handler to remove a user as admin of the current tournament.

GET	/j/tournaments/[0-9]+/admin/remove/

func Reset

func Reset(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Reset handler, use it to reset points and goals of a tournament.

func Search(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Search is the handler allowing to get all the tournaments that match the query.

func Show

func Show(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Show handler, use it to get the data of a specific tournament.

func SimulateMatches

func SimulateMatches(w http.ResponseWriter, r *http.Request, u *mdl.User) error

SimulateMatches simulates the scores of a phase in a tournament.

POST /j/tournaments/[0-9]+/matches/simulate?phase=:phaseName

func Teams

func Teams(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Teams is the Tournament teams handler: Use this handler to get the teams of a tournament. Returns an array of teams, You can specify the groupby parameter to be "phase".

GET	/j/tournament/[0-9]+/teams/

The response is an array of teams group by phase.

func Update

func Update(w http.ResponseWriter, r *http.Request, u *mdl.User) error

Update is the hanlder allowing to update a tournament.

func UpdateMatchResult

func UpdateMatchResult(w http.ResponseWriter, r *http.Request, u *mdl.User) error

UpdateMatchResult is the handler allowing to update match of tournament with results information. from parameter 'result' with format 'result1 result2' the match information is updated accordingly.

func UpdateTeam

func UpdateTeam(w http.ResponseWriter, r *http.Request, u *mdl.User) error

UpdateTeam is the Update team handler. replaces a team for the second phase of the tournament.

Types

type ByDate

type ByDate []DayJSON

ByDate type implements the sort.Interface for []DayJSON based on the date field.

func (ByDate) Len

func (a ByDate) Len() int

func (ByDate) Less

func (a ByDate) Less(i, j int) bool

func (ByDate) Swap

func (a ByDate) Swap(i, j int)

type DayJSON

type DayJSON struct {
	Date    time.Time
	Matches []MatchJSON
}

DayJSON is a variable to hold a date and match field. We use it to group tournament matches information by days.

type DayWithPredictionJSON

type DayWithPredictionJSON struct {
	Date    time.Time
	Matches []MatchWithPredictionJSON
}

DayWithPredictionJSON is a variable to hold a date and match with prediction.

type GroupJSON

type GroupJSON struct {
	Name  string
	Teams []TeamJSON
}

A GroupJSON is a variable to hold a the name of a group and an array of Teams. We use it to group tournament teams information by group to meet world cup organization.

type MatchJSON

type MatchJSON struct {
	Id         int64 `json:"Id"`
	IdNumber   int64 `json:"IdNumber"`
	Date       time.Time
	Team1      string
	Team2      string
	Iso1       string
	Iso2       string
	Location   string
	Result1    int64
	Result2    int64
	HasPredict bool
	Predict    string
	Finished   bool
	Ready      bool
	CanPredict bool
}

MatchJSON is a variable to hold of match information.

type MatchWithPredictionJSON

type MatchWithPredictionJSON struct {
	Match        MatchJSON
	Participants []UserPredictionJSON
}

MatchWithPredictionJSON is a variable to hold a match and an array of participants who put a predict on the match.

type PhaseJSON

type PhaseJSON struct {
	Name      string
	Days      []DayJSON
	Completed bool
}

PhaseJSON is a variable to hold a the name of a phase and an array of days. We use it to group tournament matches information by phases.

type TeamJSON

type TeamJSON struct {
	Name   string
	Points int64
	GoalsF int64
	GoalsA int64
	Iso    string
}

A TeamJSON is a variable to hold the basic information of a Team: The name of the team, the number of points recorded in the group phase, the goals for and against.

type TournamentData

type TournamentData struct {
	Name        string
	Description string
}

TournamentData holds the name and the description of a tournament.

type UserPredictionJSON

type UserPredictionJSON struct {
	Id       int64 `json:"Id,omitempty"`
	Username string
	Alias    string
	Predict  string
}

UserPredictionJSON is a variable to hold user data and a prediction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL