models

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB() *gorm.DB

Types

type Match

type Match struct {
	gorm.Model
	Tournament   Tournament `gorm:"ForeignKey:TournamentID"`
	TournamentID uint
	Team1        Team `gorm:"ForeignKey:Team1ID"`
	Team1ID      uint
	Team2        Team `gorm:"ForeignKey:Team2ID"`
	Team2ID      uint
	Team1Score   int `sql:"DEFAULT:-1"`
	Team2Score   int `sql:"DEFAULT:-1"`

	Mem1EloBefore int
	Mem1EloAfter  int
	Mem2EloBefore int
	Mem2EloAfter  int
	Mem3EloBefore int
	Mem3EloAfter  int
	Mem4EloBefore int
	Mem4EloAfter  int
}

func (*Match) GetMatchInfo

func (match *Match) GetMatchInfo(newMatch Match)

func (Match) UpdateElo

func (match Match) UpdateElo(db *gorm.DB)

type Member

type Member struct {
	gorm.Model
	Username string `gorm:"not null;unique" json:"username"`
	Elo      int    `json:"elo" sql:"DEFAULT:1000"`
}

func (Member) AddElo

func (member Member) AddElo(db *gorm.DB, amount int)

type Score

type Score struct {
	Team1Score int `json:"score_team_1"`
	Team2Score int `json:"score_team_2"`
}

type Team

type Team struct {
	gorm.Model
	Tournament    Tournament `gorm:"ForeignKey:TournamentID"`
	TournamentID  uint
	Member1       Member `gorm:"ForeignKey:Member1ID"`
	Member1ID     uint
	Member2       Member `gorm:"ForeignKey:Member2ID"`
	Member2ID     uint
	PlayedMatches int
	GF            int
	GA            int
	GD            int
	Points        int
}

func (Team) AvgElo

func (team Team) AvgElo(db *gorm.DB) float64

func (*Team) LoadMembers

func (team *Team) LoadMembers(db *gorm.DB)

func (Team) UpdateElo

func (team Team) UpdateElo(db *gorm.DB, elo float64)

func (Team) UpdateTeamScore

func (team Team) UpdateTeamScore(db *gorm.DB)

type TeamRequest

type TeamRequest struct {
	Teams []struct {
		Member1_id int `json:"member1_id"`
		Member2_id int `json:"member2_id"`
	} `json:"teams"`
}

type Tournament

type Tournament struct {
	gorm.Model

	Matches []Match `gorm:"ForeignKey:TournamentID"`
	Teams   []Team  `gorm:"ForeignKey:TournamentID"`
}

func (*Tournament) CreateMatches

func (tour *Tournament) CreateMatches(db *gorm.DB, teams []Team) []Match

func (*Tournament) CreateTeams

func (tour *Tournament) CreateTeams(db *gorm.DB, request TeamRequest) []Team

func (Tournament) Delete

func (tour Tournament) Delete(db *gorm.DB)

Jump to

Keyboard shortcuts

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