models

package
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: 18 Imported by: 0

Documentation

Overview

Package models provides the entities used in gonawin app.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccuracyKeyByID

func AccuracyKeyByID(c appengine.Context, id int64) *datastore.Key

AccuracyKeyByID gets an accuracy key given an id.

func AddScores

func AddScores(c appengine.Context, tournamentScores []*Score, scores []int64) error

AddScores adds new scores to each score entity and update all scores at the end.

func AddToTeamInvertedIndex

func AddToTeamInvertedIndex(c appengine.Context, name string, id int64) error

AddToTeamInvertedIndex adds name to team inverted index entity.

We do this by spliting the name in words (split by spaces), for each word we check if it already exists a team inverted index entity. If it does not yet exist, we create an entity with the word as key and team id as value.

func AddToTournamentInvertedIndex

func AddToTournamentInvertedIndex(c appengine.Context, name string, id int64) error

AddToTournamentInvertedIndex adds name to tournament inverted index entity.

We do this by spliting the name in words (split by spaces), for each word we check if it already exists a team inverted index entity. If it does not yet exist, we create an entity with the word as key and tournament id as value.

func AddToUserInvertedIndex

func AddToUserInvertedIndex(c appengine.Context, name string, id int64) error

AddToUserInvertedIndex add a name the user inverted index entity.

We do this by spliting the name in words (split by spaces), for each word we check if it already exists a user inverted index entity. If it does not yet exist, we create an entity with the word as key and user id as value.

func DestroyActivities

func DestroyActivities(c appengine.Context, activityIds []int64) error

DestroyActivities deletes activities in array.

func DestroyGroups

func DestroyGroups(c appengine.Context, groupIDs []int64) error

DestroyGroups destroys an array of groups.

func DestroyMatches

func DestroyMatches(c appengine.Context, matchIds []int64) error

DestroyMatches destroys an array of matches.

func DestroyPredicts

func DestroyPredicts(c appengine.Context, predictIds []int64) error

DestroyPredicts destroys a list of predicts.

func GenerateAuthKey

func GenerateAuthKey() string

GenerateAuthKey generates authentication string key. We use this function to create an authentication token for a user entity.

func GetTeamFrequencyForWord

func GetTeamFrequencyForWord(c appengine.Context, word string) (int64, error)

GetTeamFrequencyForWord gets the number of teams that have 'word' in their name.

func GetTeamInvertedIndexes

func GetTeamInvertedIndexes(c appengine.Context, words []string) ([]int64, error)

GetTeamInvertedIndexes returns, Given an array of words, an array of indexes that correspond to the team ids of the teams that use these words.

func GetTournamentFrequencyForWord

func GetTournamentFrequencyForWord(c appengine.Context, word string) (int64, error)

GetTournamentFrequencyForWord gets the number of tournaments that have 'word' in their name.

func GetTournamentInvertedIndexes

func GetTournamentInvertedIndexes(c appengine.Context, words []string) ([]int64, error)

GetTournamentInvertedIndexes returns an array of indexes that correspond to the tournament ids of the tournaments that use these words.

func GetUserFrequencyForWord

func GetUserFrequencyForWord(c appengine.Context, word string) (int64, error)

GetUserFrequencyForWord gets the number of users that have 'word' in their name.

func GetUserInvertedIndexes

func GetUserInvertedIndexes(c appengine.Context, words []string) ([]int64, error)

GetUserInvertedIndexes returns, Given an array of words, an array of indexes that correspond to the user ids of the users that use these words.

func GetWordFrequencyForTeam

func GetWordFrequencyForTeam(c appengine.Context, Id int64, word string) int64

GetWordFrequencyForTeam will get the frequency of that word in the team terms given a id, and a word.

func GetWordFrequencyForTournament

func GetWordFrequencyForTournament(c appengine.Context, id int64, word string) int64

GetWordFrequencyForTournament gets the frequency of given word with respect to tournament id.

func GetWordFrequencyForUser

func GetWordFrequencyForUser(c appengine.Context, id int64, word string) int64

GetWordFrequencyForUser gets the frequency of given word with respect to user id.

func GroupKeyByID

func GroupKeyByID(c appengine.Context, Id int64) *datastore.Key

GroupKeyByID gets pointer to a group key given a group id.

func IsTeamAdmin

func IsTeamAdmin(c appengine.Context, teamID int64, userID int64) bool

IsTeamAdmin checks if user is admin of the team with id 'teamId'.

func IsTournamentAdmin

func IsTournamentAdmin(c appengine.Context, tournamentId int64, userID int64) bool

IsTournamentAdmin checks if user is admin of tournament with id 'tournamentId'.

func MapOfIDTeams

func MapOfIDTeams(c appengine.Context, tournament *Tournament) map[int64]string

MapOfIDTeams is the map of team IDs of a given tournament.

func MatchKeyByID

func MatchKeyByID(c appengine.Context, id int64) *datastore.Key

MatchKeyByID returns a pointer to a match key given a match id.

func PredictKeyByID

func PredictKeyByID(c appengine.Context, id int64) *datastore.Key

PredictKeyByID gets a Predict key given an id.

func PredictKeysByIds

func PredictKeysByIds(c appengine.Context, ids []int64) []*datastore.Key

PredictKeysByIds returns an array of keys with respect to a given array of ids.

func PriceKeyByID

func PriceKeyByID(c appengine.Context, id int64) *datastore.Key

PriceKeyByID gets a Price key given an id.

func SaveActivities

func SaveActivities(c appengine.Context, activities []*Activity) error

SaveActivities updates an array of users.

func SaveScores

func SaveScores(c appengine.Context, scores []*Score, keys []*datastore.Key) error

SaveScores saves an array of scores to the datastore.

func ScoreKeyByID

func ScoreKeyByID(c appengine.Context, id int64) *datastore.Key

ScoreKeyByID gets a score key given an id.

func SetResult

func SetResult(c appengine.Context, m *Tmatch, result1 int64, result2 int64, t *Tournament) error

SetResult sets the result of a match entity and triggers a match update in datastore and score updates.

func SetResults

func SetResults(c appengine.Context, matches []*Tmatch, results1 []int64, results2 []int64, t *Tournament) error

SetResults sets results on an array of matches and triggers a match update and group update.

func TeamInvertedIndexGetWordCount

func TeamInvertedIndexGetWordCount(c appengine.Context) (int64, error)

TeamInvertedIndexGetWordCount returns the current number of words on team names.

func TeamInvertedIndexKeyByID

func TeamInvertedIndexKeyByID(c appengine.Context, id int64) *datastore.Key

TeamInvertedIndexKeyByID returns, given an id, a pointer to the corresponding key of a team inverted index entity if found.

func TeamKeyByID

func TeamKeyByID(c appengine.Context, Id int64) *datastore.Key

TeamKeyByID gets a team key given a team id.

func TeamScore

func TeamScore(c appengine.Context, query string, ids []int64) []int64

TeamScore computes a score vector, given a query string and an array of ids,

that has the doc ids and the score of each id with respect to the query.

func TeamsKeysByIDs

func TeamsKeysByIDs(c appengine.Context, IDs []int64) []*datastore.Key

TeamsKeysByIDs returns an array of datastore keys from a given team IDs array.

func TournamentInvertedIndexGetWordCount

func TournamentInvertedIndexGetWordCount(c appengine.Context) (int64, error)

TournamentInvertedIndexGetWordCount gets the number of words used in tournament names.

func TournamentInvertedIndexKeyByID

func TournamentInvertedIndexKeyByID(c appengine.Context, id int64) *datastore.Key

TournamentInvertedIndexKeyByID gets a key pointer to a tournament inverted index entity given an id.

func TournamentKeyByID

func TournamentKeyByID(c appengine.Context, id int64) *datastore.Key

TournamentKeyByID gets a pointer to a tournament key given a tournament id.

func TournamentKeysByIds

func TournamentKeysByIds(c appengine.Context, ids []int64) []*datastore.Key

TournamentKeysByIds finds tournaments keys from an array of ids.

func TournamentScore

func TournamentScore(c appengine.Context, query string, ids []int64) []int64

TournamentScore computes a score vector, given a query string and an array of ids, that has the doc ids and the score of each id with respect to the query.

func UpdateGroup

func UpdateGroup(c appengine.Context, g *Tgroup) error

UpdateGroup updates a group.

func UpdateGroups

func UpdateGroups(c appengine.Context, groups []*Tgroup) error

UpdateGroups updates an array of groups.

func UpdateMatch

func UpdateMatch(c appengine.Context, m *Tmatch) error

UpdateMatch updates a match.

func UpdateMatches

func UpdateMatches(c appengine.Context, matches []*Tmatch) error

UpdateMatches updates an array of matches.

func UpdateNextPhase

func UpdateNextPhase(c appengine.Context, t *Tournament, currentphase *Tphase, nextphase *Tphase) error

UpdateNextPhase updates next phase in tournament.

func UpdatePointsAndGoals

func UpdatePointsAndGoals(c appengine.Context, g *Tgroup, m *Tmatch, tournament *Tournament) error

UpdatePointsAndGoals update points in group with result of match.

func UpdateScores

func UpdateScores(c appengine.Context, scores []*Score) error

UpdateScores updates an array of scores.

func UpdateTeamInvertedIndex

func UpdateTeamInvertedIndex(c appengine.Context, oldname string, newname string, id int64) error

UpdateTeamInvertedIndex updates the Team inverted index. From the old team name and the new team name we handle the removal of the words that are no longer present and the addition of new words.

func UpdateTeams

func UpdateTeams(c appengine.Context, teams []*Team) error

UpdateTeams updates an array of teams.

func UpdateTournamentInvertedIndex

func UpdateTournamentInvertedIndex(c appengine.Context, oldname string, newname string, id int64) error

UpdateTournamentInvertedIndex updates a team inverted index given an oldname, a new name and an id.

func UpdateUserInvertedIndex

func UpdateUserInvertedIndex(c appengine.Context, oldname string, newname string, id int64) error

UpdateUserInvertedIndex updates the User inverted index. From the old user name and the new user name we handle the removal of the words that are no longer present and the addition of new words.

func UpdateUsers

func UpdateUsers(c appengine.Context, users []*User) error

UpdateUsers updates an array of users.

func UserInvertedIndexGetWordCount

func UserInvertedIndexGetWordCount(c appengine.Context) (int64, error)

UserInvertedIndexGetWordCount returns the current number of words on user names.

func UserInvertedIndexKeyByID

func UserInvertedIndexKeyByID(c appengine.Context, id int64) *datastore.Key

UserInvertedIndexKeyByID returns, given an id, a pointer to the corresponding key of a user inverted index entity if found.

func UserKeyByID

func UserKeyByID(c appengine.Context, id int64) *datastore.Key

UserKeyByID gets key pointer given a user id.

func UserKeysByIds

func UserKeysByIds(c appengine.Context, ids []int64) []*datastore.Key

UserKeysByIds gets user keys given a list of user ids.

func UserScore

func UserScore(c appengine.Context, query string, ids []int64) []int64

UserScore computes a score vector, given a query string and an array of ids, that has the doc ids and the score of each id with respect to the query.

func WasTeamRequestSent

func WasTeamRequestSent(c appengine.Context, teamID int64, userID int64) bool

WasTeamRequestSent checks if for a team id, user id pair, a request was sent.

Types

type AccOfTournaments

type AccOfTournaments struct {
	AccuracyId   int64 // id of accuracy entity
	TournamentId int64 // id of tournament
}

AccOfTournaments holds a tournament id and an accuracy id.

type Accuracy

type Accuracy struct {
	Id           int64
	TeamId       int64
	TournamentId int64
	Accuracies   []float64
}

Accuracy is a placeholder for progression of the accuracy of a team in a tournament. Teams should have a global accuracy as well as an accuracy for each tournament they participate in. Teams should be able to see the evolution of their accuracy for each tournament.

The Team accuracy of a specific tournament is computed as follows:

(sum(scores of match for each team member) + previous accuracy) / (number of matches played by the team)

If some participants arrive later to the tournament, previous accuracies count as 0, and this does not impact previous teams accuracy.

func AccuracyByID

func AccuracyByID(c appengine.Context, id int64) (*Accuracy, error)

AccuracyByID gets a team given an id.

func CreateAccuracy

func CreateAccuracy(c appengine.Context, teamID int64, tournamentId int64, oldmatches int) (*Accuracy, error)

CreateAccuracy creates an Accuracy entity.

func (*Accuracy) Add

func (a *Accuracy) Add(c appengine.Context, acc float64) (float64, error)

Add accuracy to array of accuracies in Accuracy entity.

func (*Accuracy) Update

func (a *Accuracy) Update(c appengine.Context) error

Update a team given an id and a team pointer.

type AccuracyJSON

type AccuracyJSON struct {
	Id           *int64     `json:"Id,omitempty"`
	TeamId       *int64     `json:"TeamId,omitempty"`
	TournamentId *int64     `json:"TournamentId,omitempty"`
	Accuracies   *[]float64 `json:",omitempty"`
}

AccuracyJSON is the JSON representation of the Accuracy entity.

type AccuracyOverall

type AccuracyOverall struct {
	Id           int64
	TournamentId int64
	Accuracy     float64       // overall accuracy
	Progression  []Progression // progression of accuracies of team in tournament. (right now the last 5 accuracy logs)
}

AccuracyOverall represents the accuracy for a tournament and its progression.

type Activity

type Activity struct {
	Id        int64
	Type      string         // Type of the activity (welcome, team, tournament, match, accuracy, predict, score)
	Verb      string         // Describes the action
	Actor     ActivityEntity // The one who/which performs the action
	Object    ActivityEntity // The one who/which is used to performs the action (can be empty)
	Target    ActivityEntity // The one who/which is affected by the action (can be empty)
	Published time.Time
	CreatorID int64
}

Activity is an update that shows the activity of the user on gonawin.

An activity can be published as long as a type, a verb and an actor has been specified.

func FindActivities

func FindActivities(c appengine.Context, u *User, count int64, page int64) []*Activity

FindActivities return activities for a specific user.

func (*Activity) AddNewActivityID

func (a *Activity) AddNewActivityID(c appengine.Context, u *User) error

AddNewActivityID adds new activity id for a specific user.

type ActivityEntity

type ActivityEntity struct {
	Id          int64 `json:"Id,omitempty"`
	Type        string
	DisplayName string // Name which will be displayed in the view
}

ActivityEntity represents the entity of an activity.

type ActivityJSON

type ActivityJSON struct {
	Id        *int64          `json:",omitempty"`
	Type      *string         `json:",omitempty"`
	Verb      *string         `json:",omitempty"`
	Actor     *ActivityEntity `json:",omitempty"`
	Object    *ActivityEntity `json:",omitempty"`
	Target    *ActivityEntity `json:",omitempty"`
	Published *time.Time      `json:",omitempty"`
	CreatorID *int64          `json:",omitempty"`
}

ActivityJSON is the JSON representation of an activity.

type ByDate

type ByDate []Tday

ByDate implements sort.Interface for []Tday 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 ChampionsLeagueTournament

type ChampionsLeagueTournament struct{}

ChampionsLeagueTournament represents the Champions League tournament.

func (ChampionsLeagueTournament) ArrayOfPhases

func (clt ChampionsLeagueTournament) ArrayOfPhases() []string

ArrayOfPhases returns an array of the phases names of champions league tournament: (QuarterFinals, SemiFinals, Finals).

func (ChampionsLeagueTournament) MapOf2ndRoundMatches

func (clt ChampionsLeagueTournament) MapOf2ndRoundMatches() map[string][][]string

MapOf2ndRoundMatches returns the Map of 2nd round matches, of the Champions League tournament. key: round number, value: array of array of strings with match information ( MatchId, MatchDate, MatchTeam1, MatchTeam2, MatchLocation)

Example:

round 4:[{"1", "Apr/14/2014", "Paris Saint-Germain", "AS Monaco FC", "Parc des Princes, Paris"}, ...]

func (ChampionsLeagueTournament) MapOfGroupMatches

func (clt ChampionsLeagueTournament) MapOfGroupMatches() map[string][][]string

MapOfGroupMatches is a map containing the matches accessible by group.

func (ChampionsLeagueTournament) MapOfGroups

func (clt ChampionsLeagueTournament) MapOfGroups() map[string][]string

MapOfGroups is a map containing the groups of a tournament. key: group name, value: string array of teams.

func (ChampionsLeagueTournament) MapOfIDTeams

func (clt ChampionsLeagueTournament) MapOfIDTeams(c appengine.Context, tournament *Tournament) map[int64]string

MapOfIDTeams builds a map of teams from tournament entity.

func (ChampionsLeagueTournament) MapOfPhaseIntervals

func (clt ChampionsLeagueTournament) MapOfPhaseIntervals() map[string][]int64

MapOfPhaseIntervals builds a map with key the corresponding phase in the champions league tournament at value a tuple that represent the match number interval in which the phase take place: Quarter-finals: matches 1 to 8 Semi-finals: matches 9 to 12 Finals: match 13

func (ChampionsLeagueTournament) MapOfTeamCodes

func (clt ChampionsLeagueTournament) MapOfTeamCodes() map[string]string

MapOfTeamCodes is map containing the team codes. key: team name, value: code example: Paris Saint-Germain: PSG

type ChampionsLeagueTournament20152016

type ChampionsLeagueTournament20152016 struct{}

func (ChampionsLeagueTournament20152016) ArrayOfPhases

func (clt ChampionsLeagueTournament20152016) ArrayOfPhases() []string

Return an array of the phases names of champions league tournament: (QuarterFinals, SemiFinals, Finals)

func (ChampionsLeagueTournament20152016) MapOf2ndRoundMatches

func (clt ChampionsLeagueTournament20152016) MapOf2ndRoundMatches() map[string][][]string

Returns the Map of 2nd round matches, of the world cup tournament. key: round number, value: array of array of strings with match information ( MatchId, MatchDate, MatchTeam1, MatchTeam2, MatchLocation)

Example:

round 4:[{"1", "Apr/14/2014", "Paris Saint-Germain", "AS Monaco FC", "Parc des Princes, Paris"}, ...]

func (ChampionsLeagueTournament20152016) MapOfGroupMatches

func (clt ChampionsLeagueTournament20152016) MapOfGroupMatches() map[string][][]string

func (ChampionsLeagueTournament20152016) MapOfGroups

func (clt ChampionsLeagueTournament20152016) MapOfGroups() map[string][]string

Map of groups, key: group name, value: string array of teams.

func (ChampionsLeagueTournament20152016) MapOfIDTeams

func (clt ChampionsLeagueTournament20152016) MapOfIDTeams(c appengine.Context, tournament *Tournament) map[int64]string

From tournament entity build map of teams.

func (ChampionsLeagueTournament20152016) MapOfPhaseIntervals

func (clt ChampionsLeagueTournament20152016) MapOfPhaseIntervals() map[string][]int64

Build a map with key the corresponding phase in the champions league tournament at value a tuple that represent the match number interval in which the phase take place: Quarter-finals: matches 1 to 8 Semi-finals: matches 9 to 12 Finals: match 13

func (ChampionsLeagueTournament20152016) MapOfTeamCodes

func (clt ChampionsLeagueTournament20152016) MapOfTeamCodes() map[string]string

Map of team codes, key: team name, value: code example: Paris Saint-Germain: PSG

type CopaAmericaTournament

type CopaAmericaTournament struct {
}

CopaAmericaTournament is a placeholder for the Copa America Tournament.

func (CopaAmericaTournament) ArrayOfPhases

func (cat CopaAmericaTournament) ArrayOfPhases() []string

ArrayOfPhases returns an array of the phases names of world cup tournament: FirstStage, RoundOf16, QuarterFinals, SemiFinals, ThirdPlace, Finals

func (CopaAmericaTournament) MapOf2ndRoundMatches

func (cat CopaAmericaTournament) MapOf2ndRoundMatches() map[string][][]string

MapOf2ndRoundMatches returns the map of 2nd round matches, of the tournament. key: round number, value: array of array of strings with match information: MatchId, MatchDate, MatchTeam1, MatchTeam2, MatchLocation

Example:

round 16:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (CopaAmericaTournament) MapOfGroupMatches

func (cat CopaAmericaTournament) MapOfGroupMatches() map[string][][]string

MapOfGroupMatches return a map with the maches of all the groups key: group name, value: array of array of strings with match information: MatchId, MatchDate, MatchTeam1, MatchTeam2, MatchLocation

Example:

Group A:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (CopaAmericaTournament) MapOfGroups

func (cat CopaAmericaTournament) MapOfGroups() map[string][]string

MapOfGroups represents the groupsof a tournament, key: group name, value: string array of teams.

func (CopaAmericaTournament) MapOfIDTeams

func (cat CopaAmericaTournament) MapOfIDTeams(c appengine.Context, tournament *Tournament) map[int64]string

MapOfIDTeams returns a map of team IDs as keys and team names as values.

func (CopaAmericaTournament) MapOfPhaseIntervals

func (cat CopaAmericaTournament) MapOfPhaseIntervals() map[string][]int64

MapOfPhaseIntervals returns a map with key the corresponding phase in the copa america tournament at value a tuple that represent the match number interval in which the phase take place: first stage: matches 1 to 48 Round of 16: matches 49 to 56 Quarte-finals: matches 57 to 60 Semi-finals: matches 61 to 62 Third Place: match 63 Finals: match 64

func (CopaAmericaTournament) MapOfTeamCodes

func (cat CopaAmericaTournament) MapOfTeamCodes() map[string]string

MapOfTeamCodes is the map of country codes, key: team name, value: ISO code example: Brazil: BR

type CopaAmericaTournament2016

type CopaAmericaTournament2016 struct {
}

CopaAmericaTournament2016 is a placeholder for the Copa America Tournament.

func (CopaAmericaTournament2016) ArrayOfPhases

func (cat CopaAmericaTournament2016) ArrayOfPhases() []string

ArrayOfPhases returns an array of the phases names of world cup tournament: FirstStage, RoundOf16, QuarterFinals, SemiFinals, ThirdPlace, Finals

func (CopaAmericaTournament2016) MapOf2ndRoundMatches

func (cat CopaAmericaTournament2016) MapOf2ndRoundMatches() map[string][][]string

MapOf2ndRoundMatches returns the map of 2nd round matches, of the tournament. key: round number, value: array of array of strings with match information: MatchId, MatchDate, MatchTeam1, MatchTeam2, MatchLocation

Example:

round 16:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (CopaAmericaTournament2016) MapOfGroupMatches

func (cat CopaAmericaTournament2016) MapOfGroupMatches() map[string][][]string

MapOfGroupMatches return a map with the maches of all the groups key: group name, value: array of array of strings with match information: MatchId, MatchDate, MatchTeam1, MatchTeam2, MatchLocation

Example:

Group A:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (CopaAmericaTournament2016) MapOfGroups

func (cat CopaAmericaTournament2016) MapOfGroups() map[string][]string

MapOfGroups represents the groupsof a tournament, key: group name, value: string array of teams.

func (CopaAmericaTournament2016) MapOfIDTeams

func (cat CopaAmericaTournament2016) MapOfIDTeams(c appengine.Context, tournament *Tournament) map[int64]string

MapOfIDTeams returns a map of team IDs as keys and team names as values.

func (CopaAmericaTournament2016) MapOfPhaseIntervals

func (cat CopaAmericaTournament2016) MapOfPhaseIntervals() map[string][]int64

MapOfPhaseIntervals returns a map with key the corresponding phase in the copa america tournament at value a tuple that represent the match number interval in which the phase take place: first stage: matches 1 to 48 Round of 16: matches 49 to 56 Quarte-finals: matches 57 to 60 Semi-finals: matches 61 to 62 Third Place: match 63 Finals: match 64

func (CopaAmericaTournament2016) MapOfTeamCodes

func (cat CopaAmericaTournament2016) MapOfTeamCodes() map[string]string

MapOfTeamCodes is the map of country codes, key: team name, value: ISO code example: Brazil: BR

type EuroTournament2016

type EuroTournament2016 struct {
}

EuroTournament2016 represents a Euro tournament.

func (EuroTournament2016) ArrayOfPhases

func (et EuroTournament2016) ArrayOfPhases() []string

ArrayOfPhases returns an array of the phases names of champions league tournament: (QuarterFinals, SemiFinals, Finals).

func (EuroTournament2016) MapOf2ndRoundMatches

func (et EuroTournament2016) MapOf2ndRoundMatches() map[string][][]string

MapOf2ndRoundMatches returns the Map of 2nd round matches, of the euro tournament. key: round number, value: array of array of strings with match information ( MatchId, MatchDate, MatchTeam1, MatchTeam2, MatchLocation)

Example:

round 16:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (EuroTournament2016) MapOfGroupMatches

func (et EuroTournament2016) MapOfGroupMatches() map[string][][]string

MapOfGroupMatches is a map containing the matches accessible by group.

Example:

Group A:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (EuroTournament2016) MapOfGroups

func (et EuroTournament2016) MapOfGroups() map[string][]string

MapOfGroups is a map containing the groups of a tournament. key: group name, value: string array of teams.

func (EuroTournament2016) MapOfIDTeams

func (et EuroTournament2016) MapOfIDTeams(c appengine.Context, tournament *Tournament) map[int64]string

MapOfIDTeams builds a map of teams from tournament entity.

func (EuroTournament2016) MapOfPhaseIntervals

func (et EuroTournament2016) MapOfPhaseIntervals() map[string][]int64

MapOfPhaseIntervals builds a map with key the corresponding phase in the world cup tournament at value a tuple that represent the match number interval in which the phase take place: first stage: matches 1 to 48 Round of 16: matches 49 to 56 Quarte-finals: matches 57 to 60 Semi-finals: matches 61 to 62 Third Place: match 63 Finals: match 64

func (EuroTournament2016) MapOfTeamCodes

func (et EuroTournament2016) MapOfTeamCodes() map[string]string

MapOfTeamCodes is map containing the team codes. key: team name, value: code example: Brazil: BR

type Predict

type Predict struct {
	Id      int64     // predict id
	UserId  int64     // user id, a prediction is binded to a single user.
	Result1 int64     // result of first team
	Result2 int64     // result of second team
	MatchId int64     // match id in tournament
	Created time.Time // date of creation
}

Predict is an entity defined by the result of a Match: Result1 and Result2 a match id and a user id.

func CreatePredict

func CreatePredict(c appengine.Context, userID, result1, result2, matchID int64) (*Predict, error)

CreatePredict creates a Predict entity given a name, a user id, a result and a match id admin id and a private mode.

func FindAllPredicts

func FindAllPredicts(c appengine.Context) []*Predict

FindAllPredicts gets all Predicts in datastore.

func FindPredictByUserMatch

func FindPredictByUserMatch(c appengine.Context, userID, matchID int64) *Predict

FindPredictByUserMatch searches for a Predict entity given a userId and a matchId. The pair (user id , match id) should be unique. So if the query returns more than one entity we return 'nil' and write in the error log.

func FindPredicts

func FindPredicts(c appengine.Context, filter string, value interface{}) []*Predict

FindPredicts searches for all Predict entities with respect to a filter and a value.

func PredictByID

func PredictByID(c appengine.Context, id int64) (*Predict, error)

PredictByID gets a Predict given an id.

func PredictsByIds

func PredictsByIds(c appengine.Context, ids []int64) ([]*Predict, error)

PredictsByIds returns an array of pointers to Predict entities with respect to an array of ids.

func (*Predict) Destroy

func (p *Predict) Destroy(c appengine.Context) error

Destroy a Predict entity.

func (*Predict) Update

func (p *Predict) Update(c appengine.Context) error

Update a Predict entity.

type Predicts

type Predicts []*Predict

Predicts holds an array of Predict entity.

func (Predicts) ContainsMatchID

func (a Predicts) ContainsMatchID(id int64) (bool, int)

ContainsMatchID indicates if a match id exists in the array of predicts

type Price

type Price struct {
	Id             int64     // price id
	TeamId         int64     // team id, a price is binded to a single team.
	TournamentId   int64     // tournament id, a price is binded to a single team.
	TournamentName string    // tournament name.
	Description    string    // the description of the price
	Created        time.Time // date of creation
}

A Price entity is defined by a description of the price that the winner gets for a specific tournament.

func CreatePrice

func CreatePrice(c appengine.Context, teamID, tournamentId int64, tournamentName string, description string) (*Price, error)

CreatePrice creates a Price entity given a description, a team id and a tournament id.

func FindPricesByTeam

func FindPricesByTeam(c appengine.Context, teamID int64) []*Price

FindPricesByTeam searches for a Predict entity given a userId and a matchId. The pair (user id , match id) should be unique. So if the query returns more than one entity we return 'nil' and write in the error log.

func PriceByID

func PriceByID(c appengine.Context, id int64) (*Price, error)

PriceByID gets a Price given an id.

func PricesByIds

func PricesByIds(c appengine.Context, ids []int64) []*Price

PricesByIds gets an array of pointers to Price entities with respect to an array of ids.

func (*Price) Destroy

func (p *Price) Destroy(c appengine.Context) error

Destroy a Price entity.

func (*Price) Update

func (p *Price) Update(c appengine.Context) error

Update a Predict entity.

type Progression

type Progression struct {
	Value float64
}

Progression holds the progression of an accuracy

type Publisher

type Publisher interface {
	Publish(c appengine.Context, activityType string, verb string, object ActivityEntity, target ActivityEntity) error
	Entity() ActivityEntity
}

Publisher interface

type Score

type Score struct {
	Id           int64
	UserId       int64
	TournamentId int64
	Scores       []int64
}

Score entity is a placeholder for progression of the score of a user in a tournament.

A User should have a score as well as a score for each tournament it participates in. It should be able to access the history of his score in a specific tournament.

The score of a user evolves following the same rules.

If the prediction matches perfectly you get a +3
If prediction matches the trend you get a +1
If the prediction does not match the match result you get +0.

func CreateScore

func CreateScore(c appengine.Context, userID int64, tournamentId int64) (*Score, error)

CreateScore creates a Score entity.

func CreateScores

func CreateScores(c appengine.Context, userIDs []int64, tournamentId int64) ([]*Score, []*datastore.Key, error)

CreateScores creates a Score entity.

func ScoreByID

func ScoreByID(c appengine.Context, id int64) (*Score, error)

ScoreByID gets a team given an id.

func ScoreByUserTournament

func ScoreByUserTournament(c appengine.Context, userID interface{}, tournamentId interface{}) []*Score

ScoreByUserTournament gets an array of scores for a user, tournament pair.

func (*Score) Add

func (s *Score) Add(c appengine.Context, score int64) error

Add adds score to array of score in Score entity.

func (*Score) Update

func (s *Score) Update(c appengine.Context) error

Update updates a score given an id and a score pointer.

type ScoreJSON

type ScoreJSON struct {
	Id           *int64   `json:",omitempty"`
	UserId       *int64   `json:",omitempty"`
	TournamentId *int64   `json:",omitempty"`
	Scores       *[]int64 `json:",omitempty"`
}

ScoreJSON is the Json version of the Score struct

type ScoreOfTournament

type ScoreOfTournament struct {
	ScoreId      int64 // id of score entity
	TournamentId int64 // id of tournament
}

ScoreOfTournament holds the user's score for a tournament.

type ScoreOverall

type ScoreOverall struct {
	Id              int64
	UserId          int64
	TournamentId    int64
	Score           int64
	LastProgression int64
}

ScoreOverall is a placeholder for the overall score of a user in different tournaments.

type Tday

type Tday struct {
	Date    time.Time
	Matches []Tmatch
}

Tday represents a tournament day. It holds the date of the day and the array of matches.

func MatchesGroupByDay

func MatchesGroupByDay(matches []Tmatch) []Tday

MatchesGroupByDay gets all matches grouped by days. Returns an array of days.

type Team

type Team struct {
	Id               int64
	KeyName          string
	Name             string
	Description      string
	AdminIds         []int64 // ids of User that are admins of the team
	Private          bool
	Created          time.Time
	UserIds          []int64            // ids of Users <=> members of the team.
	TournamentIds    []int64            // ids of Tournaments <=> Tournaments the team subscribed.
	Accuracy         float64            // Overall Team accuracy.
	AccOfTournaments []AccOfTournaments // ids of Accuracies for each tournament the team is participating on .
	PriceIds         []int64            // ids of Prices <=> prices defined for each tournament the team participates.
	MembersCount     int64              // number of members in team
}

Team holds tournament entity data.

func CreateTeam

func CreateTeam(c appengine.Context, name string, description string, adminID int64, private bool) (*Team, error)

CreateTeam creates a team given a name, description, an admin id and a private mode.

func FindAllTeams

func FindAllTeams(c appengine.Context) []*Team

FindAllTeams gets all teams in datastore.

func FindTeams

func FindTeams(c appengine.Context, filter string, value interface{}) []*Team

FindTeams searches for all Team entities with respect of a filter and a value.

func GetNotJoinedTeams

func GetNotJoinedTeams(c appengine.Context, u *User, count, page int64) []*Team

GetNotJoinedTeams gets all teams that a user has not joined with respect to the count and page.

func TeamByID

func TeamByID(c appengine.Context, Id int64) (*Team, error)

TeamByID gets a team given an id.

func TeamsByIDs

func TeamsByIDs(c appengine.Context, IDs []int64) ([]*Team, error)

TeamsByIDs returns an array of teams from a given team IDs array. An error could be returned.

func (*Team) Accuracies

func (t *Team) Accuracies(c appengine.Context) []*Accuracy

Accuracies returns an array of accuracy the user is involved in.

func (*Team) AccuraciesGroupByTournament

func (t *Team) AccuraciesGroupByTournament(c appengine.Context, limit int) *[]AccuracyOverall

AccuraciesGroupByTournament gets an array of type accuracyOverall which holds the accuracy information and the last 5 progression of each tournament.

func (*Team) AccuracyByTournament

func (t *Team) AccuracyByTournament(c appengine.Context, tour *Tournament) *AccuracyOverall

AccuracyByTournament gets the overall accuracy of a team in the specified tournament. the progression of accuracies is in reverse order to have the most reset accuracy as first element.

func (*Team) AddAdmin

func (t *Team) AddAdmin(c appengine.Context, id int64) error

AddAdmin adds user to admins of current team. In order to be an admin of a team you should first be a member of the team.

func (*Team) AddPriceID

func (t *Team) AddPriceID(c appengine.Context, pID int64) error

AddPriceID adds a tournament Id in the TournamentId array.

func (*Team) AddTournamentAccuracy

func (t *Team) AddTournamentAccuracy(c appengine.Context, accuracyID int64, tournamentId int64) error

AddTournamentAccuracy adds accuracy to team entity and run update.

func (*Team) AddTournamentID

func (t *Team) AddTournamentID(c appengine.Context, tID int64) error

AddTournamentID adds a tournament Id in the TournamentId array.

func (*Team) AddUserID

func (t *Team) AddUserID(c appengine.Context, uID int64) error

AddUserID adds a team Id in the UserId array.

func (*Team) AddUserToTournaments

func (t *Team) AddUserToTournaments(c appengine.Context, uID int64) error

AddUserToTournaments add user to teams current tournaments.

func (*Team) ContainsAdminID

func (t *Team) ContainsAdminID(id int64) (bool, int)

ContainsAdminID checks if user is admin of team.

func (*Team) ContainsPriceID

func (t *Team) ContainsPriceID(id int64) (bool, int)

ContainsPriceID checks if a given price id exists in a team entity.

func (*Team) ContainsTournamentID

func (t *Team) ContainsTournamentID(id int64) (bool, int)

ContainsTournamentID checks if a given tournament id exists in a team entity.

func (*Team) ContainsUserID

func (t *Team) ContainsUserID(id int64) (bool, int)

ContainsUserID checks if user is part of team.

func (*Team) Destroy

func (t *Team) Destroy(c appengine.Context) error

Destroy a team given a team id.

func (*Team) Entity

func (t *Team) Entity() ActivityEntity

Entity is the Activity entity representation of a team

func (*Team) Join

func (t *Team) Join(c appengine.Context, u *User) error

Join let a user join a team. TeamId is added to user entity. UserId is added to team entity. UserId is added to all current tournaments joined by the team entity.

func (*Team) Joined

func (t *Team) Joined(c appengine.Context, u *User) bool

Joined checks if a user has joined a team or not.

func (*Team) Leave

func (t *Team) Leave(c appengine.Context, u *User) error

Leave makes a user leave a team. Todo: Should we check that the user is indeed a member of the team?

func (*Team) Players

func (t *Team) Players(c appengine.Context) ([]*User, error)

Players returns an array of users/ players that participates the given team.

func (*Team) PriceByTournament

func (t *Team) PriceByTournament(c appengine.Context, tid int64) *Price

PriceByTournament get the price of a tournament

func (*Team) Prices

func (t *Team) Prices(c appengine.Context) []*Price

Prices get the prices of a team.

func (*Team) Publish

func (t *Team) Publish(c appengine.Context, activityType string, verb string, object ActivityEntity, target ActivityEntity) error

Publish publishes new team activity.

func (*Team) RankingByUser

func (t *Team) RankingByUser(c appengine.Context, limit int) []*User

RankingByUser returns an array of user sorted by their score.

func (*Team) RemoveAdmin

func (t *Team) RemoveAdmin(c appengine.Context, id int64) error

RemoveAdmin remove user of admins array in current team. In order to remove an admin from a team, there should be at least an admin in the array.

func (*Team) RemovePriceByTournamentID

func (t *Team) RemovePriceByTournamentID(c appengine.Context, tID int64) error

RemovePriceByTournamentID removes price enity and price id from team enity with respect to tournament id.

func (*Team) RemoveTournamentID

func (t *Team) RemoveTournamentID(c appengine.Context, tID int64) error

RemoveTournamentID removes a tournament Id in the TournamentId array.

func (*Team) RemoveUserID

func (t *Team) RemoveUserID(c appengine.Context, uID int64) error

RemoveUserID removes a user Id in the UserId array.

func (*Team) TournamentAcc

func (t *Team) TournamentAcc(c appengine.Context, tournament *Tournament) (*Accuracy, error)

TournamentAcc returns the accury of a given team and for a given tournament.

func (*Team) Tournaments

func (t *Team) Tournaments(c appengine.Context) []*Tournament

Tournaments return an array of tournament the team is involved in.

func (*Team) Update

func (t *Team) Update(c appengine.Context) error

Update updates a team given an id and a team pointer.

func (*Team) UpdateAccuracy

func (t *Team) UpdateAccuracy(c appengine.Context, tID int64, newAccuracy float64) error

UpdateAccuracy updates the global accuracy for team, with new accuracy and accuracies of other tournaments. From all accuracies of tournaments the team participates on we sum the overall accuracies. Overall accuracy is it's last element in the array of accuracies. We then normalize by the number of tournaments the teams participates on.

type TeamByAccuracy

type TeamByAccuracy []*Team

TeamByAccuracy holds array of teams sorted by their accuracy

func (TeamByAccuracy) Len

func (a TeamByAccuracy) Len() int

func (TeamByAccuracy) Less

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

func (TeamByAccuracy) Swap

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

type TeamInvertedIndex

type TeamInvertedIndex struct {
	Id      int64
	KeyName string
	TeamIds []byte
}

TeamInvertedIndex holds informations needed for Team indexing.

func CreateTeamInvertedIndex

func CreateTeamInvertedIndex(c appengine.Context, word string, teamIds string) (*TeamInvertedIndex, error)

CreateTeamInvertedIndex creates a teaminvertedindex entity given a word and a list of ids as a string.

func FindTeamInvertedIndex

func FindTeamInvertedIndex(c appengine.Context, filter string, value interface{}) (*TeamInvertedIndex, error)

FindTeamInvertedIndex looks for an entity in the datastore given a filter and a value .

type TeamInvertedIndexJSON

type TeamInvertedIndexJSON struct {
	Id      *int64  `json:",omitempty"`
	KeyName *string `json:",omitempty"`
	TeamIds *[]byte `json:",omitempty"`
}

TeamInvertedIndexJSON is the JSON representation of TeamInvertedIndex.

type TeamJSON

type TeamJSON struct {
	Id               *int64              `json:",omitempty"`
	KeyName          *string             `json:",omitempty"`
	Name             *string             `json:",omitempty"`
	Description      *string             `json:",omitempty"`
	AdminIds         *[]int64            `json:",omitempty"`
	Private          *bool               `json:",omitempty"`
	Created          *time.Time          `json:",omitempty"`
	UserIds          *[]int64            `json:",omitempty"`
	TournamentIds    *[]int64            `json:",omitempty"`
	Accuracy         *float64            `json:",omitempty"`
	AccOfTournaments *[]AccOfTournaments `json:",omitempty"`
	PriceIds         *[]int64            `json:",omitempty"`
	MembersCount     *int64              `json:",omitempty"`
}

TeamJSON is the JSON version of the Team struct.

type TeamRequest

type TeamRequest struct {
	Id       int64
	TeamId   int64
	TeamName string
	UserId   int64
	UserName string
	Created  time.Time
}

TeamRequest represents a request to join a team.

func CreateTeamRequest

func CreateTeamRequest(c appengine.Context, teamID int64, teamName string, userID int64, userName string) (*TeamRequest, error)

CreateTeamRequest creates a teamrequest with params teamid and userid.

func FindTeamRequest

func FindTeamRequest(c appengine.Context, filter string, value interface{}) []*TeamRequest

FindTeamRequest searches for all TeamRequest entities with respect of a filter and a value.

func TeamRequestByID

func TeamRequestByID(c appengine.Context, id int64) (*TeamRequest, error)

TeamRequestByID returns a teamrequest if it exist given a teamrequestid.

func TeamsRequests

func TeamsRequests(c appengine.Context, teams []*Team) []*TeamRequest

TeamsRequests returns an array of teamRequest entities from an array of teams.

func (*TeamRequest) Destroy

func (tr *TeamRequest) Destroy(c appengine.Context) error

Destroy a team request given a teamrequestid.

type TeamRequestJSON

type TeamRequestJSON struct {
	Id       *int64     `json:",omitempty"`
	TeamId   *int64     `json:",omitempty"`
	TeamName *string    `json:",omitempty"`
	UserId   *int64     `json:",omitempty"`
	UserName *string    `json:",omitempty"`
	Created  *time.Time `json:",omitempty"`
}

TeamRequestJSON is JSON representation of the TeamRequest entity.

type Tgroup

type Tgroup struct {
	Id      int64
	Name    string
	Teams   []Tteam
	Matches []Tmatch
	Points  []int64
	GoalsF  []int64
	GoalsA  []int64
}

Tgroup represents the group of teams of a tournament

func GroupByID

func GroupByID(c appengine.Context, groupID int64) (*Tgroup, error)

GroupByID gets a Tgroup entity by id.

func Groups

func Groups(c appengine.Context, groupIDs []int64) []*Tgroup

Groups gets an array of groups entities (Tgroup) from an array of group ids.

type Tmatch

type Tmatch struct {
	Id         int64     // datastore match id
	IdNumber   int64     // id of match in tournament
	Date       time.Time // date of match
	TeamId1    int64     // id of 1st team
	TeamId2    int64     // id of 2nd team
	Location   string    // match location
	Rule       string    // we use this field to store a specific match rule.
	Result1    int64     // result of 1st team
	Result2    int64     // result of 2nd team
	Finished   bool      // is match finished
	Ready      bool      // is match ready for predictions.
	CanPredict bool      // can user make a prediction (used to block predictions when match has started).
}

Tmatch represents a tournament match.

func GetAllMatchesFromTournament

func GetAllMatchesFromTournament(c appengine.Context, tournament *Tournament) []*Tmatch

GetAllMatchesFromTournament gets an array of all matches of a tournament.

func GetMatchByIDNumber

func GetMatchByIDNumber(c appengine.Context, tournament Tournament, matchInternalID int64) *Tmatch

GetMatchByIDNumber gets match entity by iDNumber.

func GetMatchesByPhase

func GetMatchesByPhase(c appengine.Context, t *Tournament, phaseName string) []*Tmatch

GetMatchesByPhase gets all matches of a specific phase.

func MatchByID

func MatchByID(c appengine.Context, matchID int64) (*Tmatch, error)

MatchByID gets a Tmatch entity by id.

func Matches

func Matches(c appengine.Context, matchIds []int64) []*Tmatch

Matches returns the corresponding array of matches from an array of ids.

type Tournament

type Tournament struct {
	Id                   int64
	KeyName              string
	Name                 string
	Description          string
	Start                time.Time
	End                  time.Time
	AdminIds             []int64 // ids of User that are admins of the team
	Created              time.Time
	GroupIds             []int64
	Matches1stStage      []int64
	Matches2ndStage      []int64
	UserIds              []int64
	TeamIds              []int64
	TwoLegged            bool
	IsFirstStageComplete bool
	Official             bool
}

Tournament holds tournament entity data.

func CreateChampionsLeague

func CreateChampionsLeague(c appengine.Context, adminID int64) (*Tournament, error)

CreateChampionsLeague create champions league tournament entity 2016.

func CreateChampionsLeague20152016

func CreateChampionsLeague20152016(c appengine.Context, adminId int64) (*Tournament, error)

Create champions league tournament entity 2015-2016.

func CreateCopaAmerica

func CreateCopaAmerica(c appengine.Context, adminID int64) (*Tournament, error)

CreateCopaAmerica create Copa America tournament entity 2015.

func CreateCopaAmerica2016

func CreateCopaAmerica2016(c appengine.Context, adminID int64) (*Tournament, error)

CreateCopaAmerica create Copa America tournament entity 2016.

func CreateEuro2016

func CreateEuro2016(c appengine.Context, adminID int64) (*Tournament, error)

CreateEuro2016 creates euro 2016 tournament.

func CreateTournament

func CreateTournament(c appengine.Context, name string, description string, start time.Time, end time.Time, adminID int64) (*Tournament, error)

CreateTournament creates tournament entity given a name and description.

func CreateWorldCup

func CreateWorldCup(c appengine.Context, adminID int64) (*Tournament, error)

CreateWorldCup creates world cup tournament entity 2014.

func CreateWorldCup2018

func CreateWorldCup2018(c appengine.Context, adminID int64) (*Tournament, error)

CreateWorldCup2018 creates world cup tournament entity 2018.

func FindAllTournaments

func FindAllTournaments(c appengine.Context, count, page int64) []*Tournament

FindAllTournaments finds all tournaments in the datastore.

func FindTournaments

func FindTournaments(c appengine.Context, filter string, value interface{}) []*Tournament

FindTournaments finds all entity tournaments with respect of a filter and value.

func TournamentByID

func TournamentByID(c appengine.Context, id int64) (*Tournament, error)

TournamentByID gets a pointer to a tournament given a tournament id.

func TournamentsByIds

func TournamentsByIds(c appengine.Context, ids []int64) ([]*Tournament, error)

TournamentsByIds finds all tournaments with respect to array of ids.

func (*Tournament) AddAdmin

func (t *Tournament) AddAdmin(c appengine.Context, id int64) error

AddAdmin sdds user to admins of current tournament. In order to be an admin of a tournament you should first be a member of the tournament.

func (*Tournament) AddTeamID

func (t *Tournament) AddTeamID(c appengine.Context, tID int64) error

AddTeamID adds a team Id in the TeamId array.

func (*Tournament) AddUserID

func (t *Tournament) AddUserID(c appengine.Context, uID int64) error

AddUserID adds a user Id in the UserId array.

func (*Tournament) AddUserIDs

func (t *Tournament) AddUserIDs(c appengine.Context, uIds []int64) error

AddUserIDs adds user ids in the tournament entity.

func (*Tournament) ContainsAdminID

func (t *Tournament) ContainsAdminID(id int64) (bool, int)

ContainsAdminID checks if user is admin of team.

func (*Tournament) ContainsTeamID

func (t *Tournament) ContainsTeamID(id int64) (bool, int)

ContainsTeamID checks if a team is part of a tournament.

func (*Tournament) ContainsUserID

func (t *Tournament) ContainsUserID(id int64) (bool, int)

ContainsUserID checks if user is part of the tournament.

func (*Tournament) Destroy

func (t *Tournament) Destroy(c appengine.Context) error

Destroy a tournament entity given a tournament id.

func (*Tournament) Entity

func (t *Tournament) Entity() ActivityEntity

Entity is the Activity entity representation of a tournament.

func (*Tournament) IsMatchInGroup

func (t *Tournament) IsMatchInGroup(c appengine.Context, m *Tmatch) (bool, *Tgroup)

IsMatchInGroup checks if the match is part of a group phase in the current tournament.

func (*Tournament) Join

func (t *Tournament) Join(c appengine.Context, u *User) error

Join let a user join a tournament.

func (*Tournament) Joined

func (t *Tournament) Joined(c appengine.Context, u *User) bool

Joined checks if a user has joined a tournament.

func (*Tournament) OldMatches

func (t *Tournament) OldMatches(c appengine.Context) int

OldMatches gets the number of matches in a tournament that are finished.

func (*Tournament) Participants

func (t *Tournament) Participants(c appengine.Context) []*User

Participants returns an array, from the tournament, of the users that participate in it.

func (*Tournament) Progress

func (t *Tournament) Progress(c appengine.Context) float64

Progress is the progression of the tournament. The progression is a number between 0 and 1 with the progression of the tournament with respect of today's date and start and end date of tournament.

func (*Tournament) Publish

func (t *Tournament) Publish(c appengine.Context, activityType string, verb string, object ActivityEntity, target ActivityEntity) error

Publish tournament activity.

func (*Tournament) RankingByTeam

func (t *Tournament) RankingByTeam(c appengine.Context, limit int) []*Team

RankingByTeam ranks teams with respect ot their accuracy in the current tournament.

func (*Tournament) RankingByUser

func (t *Tournament) RankingByUser(c appengine.Context, limit int) []*User

RankingByUser ranks users with respect to their score in current tournament. Sets the user score to the current tournament score and return array of users sorted by that score.

func (*Tournament) RemoveAdmin

func (t *Tournament) RemoveAdmin(c appengine.Context, id int64) error

RemoveAdmin removes user of admins array in current tournament. In order to remove an admin from a team, there should be at least an admin in the array.

func (*Tournament) RemoveTeamID

func (t *Tournament) RemoveTeamID(c appengine.Context, tID int64) error

RemoveTeamID adds a team Id in the TeamId array.

func (*Tournament) RemoveUserID

func (t *Tournament) RemoveUserID(c appengine.Context, uID int64) error

RemoveUserID removes a user Id in the UserId array.

func (*Tournament) Reset

func (t *Tournament) Reset(c appengine.Context) error

Reset tournament values: Points, GoalsF, GoalsA to zero.

func (*Tournament) TeamJoin

func (t *Tournament) TeamJoin(c appengine.Context, team *Team) error

TeamJoin joins a teams to the Tournament.

func (*Tournament) TeamJoined

func (t *Tournament) TeamJoined(c appengine.Context, team *Team) bool

TeamJoined checks if a Team has joined the tournament.

func (*Tournament) TeamLeave

func (t *Tournament) TeamLeave(c appengine.Context, team *Team) error

TeamLeave leaves a team from the Tournament.

func (*Tournament) Teams

func (t *Tournament) Teams(c appengine.Context) []*Team

Teams returns an array of teams involved in tournament, from a tournament.

func (*Tournament) Update

func (t *Tournament) Update(c appengine.Context) error

Update a tournament given a tournament id and a tournament pointer.

func (*Tournament) UpdateTeamsAccuracy

func (t *Tournament) UpdateTeamsAccuracy(c appengine.Context, m *Tmatch) error

UpdateTeamsAccuracy updates the accuracy of the teams members in a specific tournament.

func (*Tournament) UpdateTournamentTeam

func (t *Tournament) UpdateTournamentTeam(c appengine.Context, phaseName, oldName, newName string) error

UpdateTournamentTeam updates a tournament team. From a phase an old name and a new, update the next phases of the tournament.

func (*Tournament) UpdateUsersScore

func (t *Tournament) UpdateUsersScore(c appengine.Context, m *Tmatch) error

UpdateUsersScore updates the score of the participants to the tournament.

type TournamentBuilder

type TournamentBuilder interface {
	MapOfTeamCodes() map[string]string
	ArrayOfPhases() []string
	MapOfGroups() map[string][]string
	MapOfGroupMatches() map[string][][]string
	MapOf2ndRoundMatches() map[string][][]string
	MapOfPhaseIntervals() map[string][]int64
	MapOfIDTeams(c appengine.Context, tournament *Tournament) map[int64]string
}

TournamentBuilder is interface used to build a tournament

func GetTournamentBuilder

func GetTournamentBuilder(t *Tournament) TournamentBuilder

GetTournamentBuilder gets the tournament builder of a given tournament.

type TournamentInvertedIndex

type TournamentInvertedIndex struct {
	Id            int64
	KeyName       string
	TournamentIds []byte
}

TournamentInvertedIndex represents the indexing date for tournament.

func CreateTournamentInvertedIndex

func CreateTournamentInvertedIndex(c appengine.Context, name string, tournamentIds string) (*TournamentInvertedIndex, error)

CreateTournamentInvertedIndex creates a tournament inverted index.

func FindTournamentInvertedIndex

func FindTournamentInvertedIndex(c appengine.Context, filter string, value interface{}) (*TournamentInvertedIndex, error)

FindTournamentInvertedIndex returns a tournament inverted index entity given a filter and its value. Returns nil if no entity was found.

type TournamentInvertedIndexJSON

type TournamentInvertedIndexJSON struct {
	Id            *int64  `json:",omitempty"`
	KeyName       *string `json:",omitempty"`
	TournamentIds *[]byte `json:",omitempty"`
}

TournamentInvertedIndexJSON is the JSON representation of the TournamentInvertedIndex struct.

type TournamentJSON

type TournamentJSON struct {
	Id                   *int64     `json:",omitempty"`
	KeyName              *string    `json:",omitempty"`
	Name                 *string    `json:",omitempty"`
	Description          *string    `json:",omitempty"`
	Start                *time.Time `json:",omitempty"`
	End                  *time.Time `json:",omitempty"`
	AdminIds             *[]int64   `json:",omitempty"`
	Created              *time.Time `json:",omitempty"`
	GroupIds             *[]int64   `json:",omitempty"`
	Matches1stStage      *[]int64   `json:",omitempty"`
	Matches2ndStage      *[]int64   `json:",omitempty"`
	UserIds              *[]int64   `json:",omitempty"`
	TeamIds              *[]int64   `json:",omitempty"`
	TwoLegged            *bool      `json:",omitempty"`
	IsFirstStageComplete *bool      `json:",omitempty"`
	Official             *bool      `json:",omitempty"`
}

TournamentJSON is the JSON version of the Tournament struct.

type Tphase

type Tphase struct {
	Name string
	Days []Tday
}

Tphase represents a tournament phase. It holds the name of the phase and the array of Tday.

func MatchesGroupByPhase

func MatchesGroupByPhase(t *Tournament, matches []*Tmatch) []Tphase

MatchesGroupByPhase gets all matches grouped by phases. Returns an array of phases.

type Tteam

type Tteam struct {
	Id   int64
	Name string
	Iso  string
}

Tteam represents a tournament team.

func TTeamByID

func TTeamByID(c appengine.Context, teamID int64) (*Tteam, error)

TTeamByID gets a Tteam entity by id.

type User

type User struct {
	Id                    int64
	Email                 string
	Username              string
	Name                  string
	Alias                 string              // name to display chosen by user if requested.
	IsAdmin               bool                // is user gonawin admin.
	Auth                  string              // authentication auth token
	PredictIds            []int64             // current user predicts.
	ArchivedPredictInds   []int64             // archived user predicts.
	TournamentIds         []int64             // current tournament ids of user <=> tournaments user subscribed.
	ArchivedTournamentIds []int64             // archived tournament ids of user <=> finnished tournametns user subscribed.
	TeamIds               []int64             // current team ids of user <=> teams user belongs to.
	Score                 int64               // overall user score.
	ScoreOfTournaments    []ScoreOfTournament // ids of Scores for each tournament the user is participating on.
	ActivityIds           []int64             // ids of user's activities
	Created               time.Time
}

User represents the User entity.

func CreateUser

func CreateUser(c appengine.Context, email, username, name, alias string, isAdmin bool, auth string) (*User, error)

CreateUser lets you create a user entity.

func FindAllUsers

func FindAllUsers(c appengine.Context) []*User

FindAllUsers finds all users present in datastore.

func FindUser

func FindUser(c appengine.Context, filter string, value interface{}) *User

FindUser searches for a user entity given a filter and value.

func FindUsers

func FindUsers(c appengine.Context, filter string, value interface{}) []*User

FindUsers finds all entity users with respect of a filter and value.

func SigninUser

func SigninUser(c appengine.Context, queryName string, email string, username string, name string) (*User, error)

SigninUser saves a user from given parameters in the datastore and return a pointer to it.

func UserByID

func UserByID(c appengine.Context, id int64) (*User, error)

UserByID finds a user entity by id.

func UsersByIds

func UsersByIds(c appengine.Context, ids []int64) ([]*User, error)

UsersByIds returns an array of pointers to Users with respect to an array of ids. It only return the found users.

func (*User) AddPredictID

func (u *User) AddPredictID(c appengine.Context, pID int64) error

AddPredictID adds a predict Id in the PredictId array.

func (*User) AddTeamID

func (u *User) AddTeamID(c appengine.Context, tID int64) error

AddTeamID adds a team Id in the TeamId array.

func (*User) AddTournamentID

func (u *User) AddTournamentID(c appengine.Context, tID int64) error

AddTournamentID adds a tournament Id in the TournamentId array.

func (*User) AddTournamentScore

func (u *User) AddTournamentScore(c appengine.Context, scoreID int64, tourID int64) error

AddTournamentScore adds accuracy to team entity and run update.

func (*User) BuildActivity

func (u *User) BuildActivity(c appengine.Context, activityType string, verb string, object ActivityEntity, target ActivityEntity) *Activity

BuildActivity build an activity.

func (*User) ContainsTeamID

func (u *User) ContainsTeamID(id int64) (bool, int)

ContainsTeamID checks if a given team id exists in the TeamId array if a user.

func (*User) ContainsTournamentID

func (u *User) ContainsTournamentID(id int64) (bool, int)

ContainsTournamentID indicates if a tournament Id exists for a user. If the tournament Id exists, its position in the slice is returned otherwise -1.

func (*User) Destroy

func (u *User) Destroy(c appengine.Context) error

Destroy lets you remove a user from the data store given a user id.

func (*User) Entity

func (u *User) Entity() ActivityEntity

Entity is the Activity entity representation of an user.

func (*User) Invitations

func (u *User) Invitations(c appengine.Context) []*Team

Invitations gets the invitations of a user.

func (*User) PredictFromMatchID

func (u *User) PredictFromMatchID(c appengine.Context, mID int64) (*Predict, error)

PredictFromMatchID returns the user predictions for a specific match.

func (*User) Publish

func (u *User) Publish(c appengine.Context, activityType string, verb string, object ActivityEntity, target ActivityEntity) error

Publish user activity.

func (*User) RemoveTeamID

func (u *User) RemoveTeamID(c appengine.Context, tID int64) error

RemoveTeamID removes a team Id in the TeamId array.

func (*User) RemoveTournamentID

func (u *User) RemoveTournamentID(c appengine.Context, tID int64) error

RemoveTournamentID removes a tournament Id in the TournamentId array.

func (*User) ScoreByTournament

func (u *User) ScoreByTournament(c appengine.Context, tID int64) int64

ScoreByTournament gets the score of user with respect to tournament. If tournament not found return 0.

func (*User) ScoreForMatch

func (u *User) ScoreForMatch(c appengine.Context, m *Tmatch) (int64, error)

ScoreForMatch returns user's score for a given match.

func (*User) Scores

func (u *User) Scores(c appengine.Context) []*Score

Scores returns an array of score entities group by tournament.

func (*User) Teams

func (u *User) Teams(c appengine.Context) []*Team

Teams returns an array of teams joined by the user.

func (*User) TeamsByPage

func (u *User) TeamsByPage(c appengine.Context, count, page int64) []*Team

TeamsByPage returns an array of teams the user is involved participates from a user id.

func (*User) TournamentScore

func (u *User) TournamentScore(c appengine.Context, tournament *Tournament) (*Score, error)

TournamentScore return user's score for a given tournament.

func (*User) Tournaments

func (u *User) Tournaments(c appengine.Context) []*Tournament

Tournaments returns an array of tournament the user is involved in from a user.

func (*User) TournamentsByPage

func (u *User) TournamentsByPage(c appengine.Context, count, page int64) []*Tournament

TournamentsByPage returns an array of tournaments the user is involved participates from a user id.

func (*User) TournamentsScores

func (u *User) TournamentsScores(c appengine.Context) []*ScoreOverall

TournamentsScores returns an array of scoreOverall entities group by tournament.

func (*User) Update

func (u *User) Update(c appengine.Context) error

Update user given a user pointer.

type UserByScore

type UserByScore []*User

UserByScore represents an array of users sortes by score.

func (UserByScore) Len

func (a UserByScore) Len() int

func (UserByScore) Less

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

func (UserByScore) Swap

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

type UserInvertedIndex

type UserInvertedIndex struct {
	Id      int64
	KeyName string
	UserIds []byte
}

UserInvertedIndex holds informations needed for User indexing.

func CreateUserInvertedIndex

func CreateUserInvertedIndex(c appengine.Context, word string, ids string) (*UserInvertedIndex, error)

CreateUserInvertedIndex creates a userinvertedindex entity given a word and a list of ids as a string.

func FindUserInvertedIndex

func FindUserInvertedIndex(c appengine.Context, filter string, value interface{}) (*UserInvertedIndex, error)

FindUserInvertedIndex looks for an entity in the datastore given a filter and a value .

type UserInvertedIndexJSON

type UserInvertedIndexJSON struct {
	Id      *int64  `json:",omitempty"`
	KeyName *string `json:",omitempty"`
	UserIds *[]byte `json:",omitempty"`
}

UserInvertedIndexJSON is the JSON representation of UserInvertedIndex.

type UserJSON

type UserJSON struct {
	Id                    *int64               `json:",omitempty"`
	Email                 *string              `json:",omitempty"`
	Username              *string              `json:",omitempty"`
	Name                  *string              `json:",omitempty"`
	Alias                 *string              `json:",omitempty"`
	IsAdmin               *bool                `json:",omitempty"`
	Auth                  *string              `json:",omitempty"`
	PredictIds            *[]int64             `json:",omitempty"`
	ArchivedPredictInds   *[]int64             `json:",omitempty"`
	TournamentIds         *[]int64             `json:",omitempty"`
	ArchivedTournamentIds *[]int64             `json:",omitempty"`
	TeamIds               *[]int64             `json:",omitempty"`
	Score                 *int64               `json:",omitempty"`
	ScoreOfTournaments    *[]ScoreOfTournament `json:",omitempty"`
	ActivityIds           *[]int64             `json:",omitempty"`
	Created               *time.Time           `json:",omitempty"`
}

UserJSON is the JSON representation of the User entity.

type UserRequest

type UserRequest struct {
	Id      int64
	TeamId  int64
	UserId  int64
	Created time.Time
}

UserRequest represents the user request entity.

func CreateUserRequest

func CreateUserRequest(c appengine.Context, teamID int64, userID int64) (*UserRequest, error)

CreateUserRequest creates a user request with params teamid and userid

func FindUserRequestByTeamAndUser

func FindUserRequestByTeamAndUser(c appengine.Context, teamID int64, userID int64) *UserRequest

FindUserRequestByTeamAndUser searches a request by team id and user id pair.

func FindUserRequests

func FindUserRequests(c appengine.Context, filter string, value interface{}) []*UserRequest

FindUserRequests searches for all TeamRequest entities with respect of a filter and a value.

func UserRequestByID

func UserRequestByID(c appengine.Context, id int64) (*UserRequest, error)

UserRequestByID returns a user request if it exist given a user request id.

func (*UserRequest) Destroy

func (ur *UserRequest) Destroy(c appengine.Context) error

Destroy a user request given a teamrequestid.

type UserRequestJSON

type UserRequestJSON struct {
	Id      *int64     `json:",omitempty"`
	TeamId  *int64     `json:",omitempty"`
	UserId  *int64     `json:",omitempty"`
	Created *time.Time `json:",omitempty"`
}

UserRequestJSON is JSON representation of the UserRequest structure.

type WordCountTeam

type WordCountTeam struct {
	Count int64
}

WordCountTeam holds a word counter for Team entities.

type WordCountTournament

type WordCountTournament struct {
	Count int64
}

WordCountTournament holds the word counter for tournaments.

type WordCountUser

type WordCountUser struct {
	Count int64
}

WordCountUser holds a word counter for User entities.

type WorldCupTournament

type WorldCupTournament struct {
}

WorldCupTournament represents a World Cup tournament.

func (WorldCupTournament) ArrayOfPhases

func (wct WorldCupTournament) ArrayOfPhases() []string

ArrayOfPhases returns an array of the phases names of champions league tournament: (QuarterFinals, SemiFinals, Finals).

func (WorldCupTournament) MapOf2ndRoundMatches

func (wct WorldCupTournament) MapOf2ndRoundMatches() map[string][][]string

MapOf2ndRoundMatches returns the Map of 2nd round matches, of the world cup tournament. key: round number, value: array of array of strings with match information ( MatchId, MatchDate, MatchTeam1, MatchTeam2, MatchLocation)

Example:

round 16:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (WorldCupTournament) MapOfGroupMatches

func (wct WorldCupTournament) MapOfGroupMatches() map[string][][]string

MapOfGroupMatches is a map containing the matches accessible by group.

Example:

Group A:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (WorldCupTournament) MapOfGroups

func (wct WorldCupTournament) MapOfGroups() map[string][]string

MapOfGroups is a map containing the groups of a tournament. key: group name, value: string array of teams.

func (WorldCupTournament) MapOfIDTeams

func (wct WorldCupTournament) MapOfIDTeams(c appengine.Context, tournament *Tournament) map[int64]string

MapOfIDTeams builds a map of teams from tournament entity.

func (WorldCupTournament) MapOfPhaseIntervals

func (wct WorldCupTournament) MapOfPhaseIntervals() map[string][]int64

MapOfPhaseIntervals builds a map with key the corresponding phase in the world cup tournament at value a tuple that represent the match number interval in which the phase take place: first stage: matches 1 to 48 Round of 16: matches 49 to 56 Quarte-finals: matches 57 to 60 Semi-finals: matches 61 to 62 Third Place: match 63 Finals: match 64

func (WorldCupTournament) MapOfTeamCodes

func (wct WorldCupTournament) MapOfTeamCodes() map[string]string

MapOfTeamCodes is map containing the team codes. key: team name, value: code example: Paris Saint-Germain: PSG

example: Brazil: BR

type WorldCupTournament2018

type WorldCupTournament2018 struct {
}

WorldCupTournament2018 represents a World Cup tournament.

func (WorldCupTournament2018) ArrayOfPhases

func (wct WorldCupTournament2018) ArrayOfPhases() []string

ArrayOfPhases returns an array of the phases names of champions league tournament: (QuarterFinals, SemiFinals, Finals).

func (WorldCupTournament2018) MapOf2ndRoundMatches

func (wct WorldCupTournament2018) MapOf2ndRoundMatches() map[string][][]string

MapOf2ndRoundMatches returns the Map of 2nd round matches, of the world cup tournament. key: round number, value: array of array of strings with match information ( MatchId, MatchDate, MatchTeam1, MatchTeam2, MatchLocation)

Example:

round 16:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (WorldCupTournament2018) MapOfGroupMatches

func (wct WorldCupTournament2018) MapOfGroupMatches() map[string][][]string

MapOfGroupMatches is a map containing the matches accessible by group.

Example:

Group A:[{"1", "Jun/12/2014", "Brazil", "Croatia", "Arena de São Paulo, São Paulo"}, ...]

func (WorldCupTournament2018) MapOfGroups

func (wct WorldCupTournament2018) MapOfGroups() map[string][]string

MapOfGroups is a map containing the groups of a tournament. key: group name, value: string array of teams.

func (WorldCupTournament2018) MapOfIDTeams

func (wct WorldCupTournament2018) MapOfIDTeams(c appengine.Context, tournament *Tournament) map[int64]string

MapOfIDTeams builds a map of teams from tournament entity.

func (WorldCupTournament2018) MapOfPhaseIntervals

func (wct WorldCupTournament2018) MapOfPhaseIntervals() map[string][]int64

MapOfPhaseIntervals builds a map with key the corresponding phase in the world cup tournament at value a tuple that represent the match number interval in which the phase take place: first stage: matches 1 to 48 Round of 16: matches 49 to 56 Quarte-finals: matches 57 to 60 Semi-finals: matches 61 to 62 Third Place: match 63 Finals: match 64

func (WorldCupTournament2018) MapOfTeamCodes

func (wct WorldCupTournament2018) MapOfTeamCodes() map[string]string

MapOfTeamCodes is map containing the team codes. key: team name, value: code example: Paris Saint-Germain: PSG

example: Brazil: BR

Jump to

Keyboard shortcuts

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