core

package module
v0.6.12 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: AGPL-3.0 Imports: 9 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortPodiums

func SortPodiums(in []Podiums)

Types

type AddContestRequest

type AddContestRequest struct {
	Name        string                      `json:"Name"`
	Description string                      `json:"Description"`
	GroupID     string                      `json:"GroupID"`
	Rounds      []CreateContestRequestRound `json:"Rounds"`
	Type        string                      `json:"Type"`
	StartTime   int64                       `json:"StartTime"`
	EndTime     int64                       `json:"EndTime"`
}

type AddPreScoreRequest added in v0.1.9

type AddPreScoreRequest struct {
	AddScoreRequest
	Source   string `json:"Source"`
	Recorder string `json:"Recorder"`
}

type AddScoreRequest

type AddScoreRequest struct {
	PlayerID  uint               `json:"PlayerID"`
	ContestID uint               `json:"ContestID"`
	Project   model.Project      `json:"Project"`
	RoundId   uint               `json:"RoundId"`
	Result    []float64          `json:"Result"`
	Penalty   model.ScorePenalty `json:"Penalty"`
}

type Bool added in v0.1.14

type Bool uint
const (
	NotBool   Bool = 0
	FalseBool Bool = 1
	TrueBool  Bool = 2
)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) AddContest

func (c *Client) AddContest(request AddContestRequest) error

func (*Client) AddPlayer

func (c *Client) AddPlayer(player model.Player) error

func (*Client) AddPlayerUser added in v0.1.24

func (c *Client) AddPlayerUser(player model.Player, user model.PlayerUser) error

func (*Client) AddPreScore added in v0.1.9

func (c *Client) AddPreScore(request AddPreScoreRequest) error

func (*Client) AddScore

func (c *Client) AddScore(req AddScoreRequest) error

score Core

func (*Client) BackToFile added in v0.5.4

func (c *Client) BackToFile() error

func (*Client) EndContestScore

func (c *Client) EndContestScore(contestId uint) error

func (*Client) GetAllContestStatics added in v0.2.1

func (c *Client) GetAllContestStatics() (contests []ContestStatics)

func (*Client) GetAllProjectBestScores

func (c *Client) GetAllProjectBestScores() (bestSingle, bestAvg map[model.Project]model.Score)

func (*Client) GetAllProjectBestScoresByTimes added in v0.4.4

func (c *Client) GetAllProjectBestScoresByTimes(startTime, endTime time.Time) (bestSingle, bestAvg map[model.Project]model.Score)

func (*Client) GetAvgRelativeSor added in v0.1.14

func (c *Client) GetAvgRelativeSor() map[model.SorStatisticsKey]RelativeSor

func (*Client) GetBestScore

func (c *Client) GetBestScore() (bestSingle, bestAvg map[model.Project][]model.Score)

func (*Client) GetBestScoreByProject

func (c *Client) GetBestScoreByProject(project model.Project) (bestSingle, bestAvg []model.Score)

func (*Client) GetBestScoreByTimes added in v0.4.4

func (c *Client) GetBestScoreByTimes(startTime, endTime time.Time) (bestSingle, bestAvg map[model.Project][]model.Score)

func (*Client) GetContest

func (c *Client) GetContest(contestId uint) (contest model.Contest, err error)

func (*Client) GetContestPodiums

func (c *Client) GetContestPodiums(contestId uint) []Podiums

func (*Client) GetContestRecord

func (c *Client) GetContestRecord(contestId uint) []RecordMessage

func (*Client) GetContestScore

func (c *Client) GetContestScore(contestId uint) map[model.Project][]RoutesScores

func (*Client) GetContestSor

func (c *Client) GetContestSor(contestId uint) (single, avg map[model.SorStatisticsKey][]SorScore)

func (*Client) GetContests

func (c *Client) GetContests(page, size int, typ string) (int64, []model.Contest, error)

func (*Client) GetPlayer

func (c *Client) GetPlayer(playerId uint) (PlayerDetail, error)

func (*Client) GetPlayerBestScore

func (c *Client) GetPlayerBestScore(playerId uint) (bestSingle, bestAvg map[model.Project]RankScore)

func (*Client) GetPlayerNemesis added in v0.1.18

func (c *Client) GetPlayerNemesis(playerID uint) NemesisDetails

func (*Client) GetPlayerPodiums

func (c *Client) GetPlayerPodiums(playerId uint) Podiums

func (*Client) GetPlayerRecord

func (c *Client) GetPlayerRecord(playerId uint) []RecordMessage

func (*Client) GetPlayerRelativeSor added in v0.1.14

func (c *Client) GetPlayerRelativeSor(playerID uint) map[model.SorStatisticsKey]RelativeSor

func (*Client) GetPlayerScore

func (c *Client) GetPlayerScore(playerId uint) (bestSingle, bestAvg []model.Score, scores []ScoresByContest)

func (*Client) GetPlayerSor

func (c *Client) GetPlayerSor(playerId uint) (single, avg map[model.SorStatisticsKey]SorScore)

func (*Client) GetPlayerUser added in v0.1.24

func (c *Client) GetPlayerUser(player model.Player) model.PlayerUser

func (*Client) GetPlayers

func (c *Client) GetPlayers(page, size int) (int64, []model.Player, error)

func (*Client) GetPodiums

func (c *Client) GetPodiums() []Podiums

func (*Client) GetPreScores added in v0.1.9

func (c *Client) GetPreScores(page, size int, final Bool) (int64, []model.PreScore, error)

func (*Client) GetPreScoresByContest added in v0.1.9

func (c *Client) GetPreScoresByContest(contestID uint, page, size int, final Bool) (int64, []model.PreScore, error)

func (*Client) GetPreScoresByPlayer added in v0.1.12

func (c *Client) GetPreScoresByPlayer(playerID uint, page, size int, final Bool) (int64, []model.PreScore, error)

func (*Client) GetRecords

func (c *Client) GetRecords(page, size int) (int64, []model.Record, error)

func (*Client) GetRelativeSor added in v0.1.6

func (c *Client) GetRelativeSor() (allPlayerSor map[model.SorStatisticsKey][]RelativeSor)

func (*Client) GetScoreByPlayerContest

func (c *Client) GetScoreByPlayerContest(playerId uint, contestId uint) ([]model.Score, error)

func (*Client) GetSor

func (c *Client) GetSor() (single, avg map[model.SorStatisticsKey][]SorScore)

func (*Client) ProcessPreScore added in v0.1.9

func (c *Client) ProcessPreScore(request ProcessPreScoreRequest) error

func (*Client) ReSetRecords added in v0.6.0

func (c *Client) ReSetRecords() error

func (*Client) RemoveContest

func (c *Client) RemoveContest(contestId uint) error

func (*Client) RemovePlayer

func (c *Client) RemovePlayer(playerId uint) error

func (*Client) RemoveScore

func (c *Client) RemoveScore(scoreID uint) error

func (*Client) UpdatePlayer

func (c *Client) UpdatePlayer(playerId uint, player model.Player) error

func (*Client) UpdatePlayerUser added in v0.1.24

func (c *Client) UpdatePlayerUser(player model.Player, user model.PlayerUser) error

type ContestCore

type ContestCore interface {
	AddContest(AddContestRequest) error                                               // 添加比赛
	RemoveContest(contestId uint) error                                               // 删除比赛
	GetAllContestStatics() (contests []ContestStatics)                                // 所有比赛的数据统计
	GetContest(contestId uint) (contest model.Contest, err error)                     // 获取信息
	GetContests(page, size int, typ string) (int64, []model.Contest, error)           // 获取比赛列表 (分页)
	GetContestSor(contestID uint) (single, avg map[model.SorStatisticsKey][]SorScore) // 获取比赛sor排名
	GetContestScore(contestID uint) map[model.Project][]RoutesScores                  // 获取比赛成绩列表
	GetContestPodiums(contestID uint) []Podiums                                       // 获取比赛领奖台
	GetContestRecord(contestID uint) []RecordMessage                                  // 获取比赛记录列表
}

type ContestStatics added in v0.2.1

type ContestStatics struct {
	model.Contest

	PlayerNum  int `json:"PlayerNum"`
	ProjectNum int `json:"ProjectNum"`
}

type Core

type Core interface {
	BackToFile() error
	ReSetRecords() error

	ScoreCore
	PlayerCore
	PlayerUserCore
	ContestCore
	StatisticalCore
}

func NewCore

func NewCore(db *gorm.DB, debug bool, cacheTime time.Duration) Core

type CreateContestRequestRound

type CreateContestRequestRound struct {
	Project model.Project `json:"Project"`
	Number  int           `json:"Number"`
	Part    int           `json:"Part"`
	Name    string        `json:"Name"`
	IsStart bool          `json:"IsStart"`
	Final   bool          `json:"Final"`
	Upsets  []string      `json:"Upsets"`
}

type NemesisDetail added in v0.1.18

type NemesisDetail struct {
	Player model.Player                  `json:"Player,omitempty"`
	Single map[model.Project]model.Score `json:"Single,omitempty"`
	Avg    map[model.Project]model.Score `json:"Avg,omitempty"`
}

type NemesisDetails added in v0.1.18

type NemesisDetails []NemesisDetail

type PlayerCore

type PlayerCore interface {
	AddPlayer(player model.Player) error                                                        // 添加玩家
	UpdatePlayer(playerId uint, player model.Player) error                                      // 更新玩家信息
	RemovePlayer(playerId uint) error                                                           // 删除玩家
	GetPlayer(playerId uint) (PlayerDetail, error)                                              // 获取玩家详细信息
	GetPlayers(page, size int) (int64, []model.Player, error)                                   // 获取玩家列表 (分页)
	GetPlayerBestScore(playerId uint) (bestSingle, bestAvg map[model.Project]RankScore)         // 获取玩家
	GetPlayerPodiums(playerID uint) Podiums                                                     // 获取玩家领奖台
	GetPlayerRecord(playerID uint) []RecordMessage                                              // 获取玩家记录
	GetPlayerScore(playerID uint) (bestSingle, bestAvg []model.Score, scores []ScoresByContest) // 获取玩家所有成绩
	GetPlayerSor(playerID uint) (single, avg map[model.SorStatisticsKey]SorScore)               // 获取玩家sor信息
	GetPlayerNemesis(playerID uint) NemesisDetails                                              // 获取玩家宿敌信息
	GetPlayerRelativeSor(playerID uint) map[model.SorStatisticsKey]RelativeSor                  // 获取单个玩家的相对排位分
}

type PlayerDetail

type PlayerDetail struct {
	model.Player

	ContestNumber       int `json:"ContestNumber,omitempty"`
	ValidRecoveryNumber int `json:"ValidRecoveryNumber,omitempty"`
	RecoveryNumber      int `json:"RecoveryNumber,omitempty"`
}

type PlayerUserCore added in v0.1.24

type PlayerUserCore interface {
	GetPlayerUser(player model.Player) model.PlayerUser                // 获取一个玩家的用户信息
	AddPlayerUser(player model.Player, user model.PlayerUser) error    // 添加一个用户信息
	UpdatePlayerUser(player model.Player, user model.PlayerUser) error // 更新一个用户信息
}

type Podiums

type Podiums struct {
	Player         model.Player    `json:"Player,omitempty"`
	Gold           int64           `json:"Gold,omitempty"`
	Silver         int64           `json:"Silver,omitempty"`
	Bronze         int64           `json:"Bronze,omitempty"`
	PodiumsResults []PodiumsResult `json:"PodiumsResults,omitempty"`
}

func (*Podiums) Add added in v0.4.1

func (p *Podiums) Add(rank int) *Podiums

type PodiumsResult

type PodiumsResult struct {
	Contest model.Contest `json:"Contest,omitempty"`
	Score   model.Score   `json:"Score,omitempty"`
}

type ProcessPreScoreRequest added in v0.1.9

type ProcessPreScoreRequest struct {
	Id           uint
	Processor    string
	FinishDetail string
}

type ProjectPlayer added in v0.3.0

type ProjectPlayer struct {
	PlayerID uint
	Project  model.Project
}

type RankScore

type RankScore struct {
	Rank  int         `json:"Rank,omitempty"` // 排名
	Score model.Score `json:"Score,omitempty"`
}

type RecordMessage

type RecordMessage struct {
	Record  model.Record  `json:"Record,omitempty"`
	Player  model.Player  `json:"Player,omitempty"`
	Score   model.Score   `json:"Score,omitempty"`
	Contest model.Contest `json:"Contest,omitempty"`
}

type RelativeSor added in v0.1.6

type RelativeSor struct {
	Player model.Player `json:"Player,omitempty"`
	// 个人成绩
	Sor float64 `json:"Sor,omitempty"`

	// 平均成绩会用到
	Avg  float64 `json:"Avg,omitempty"`  // 全部平均
	Top5 float64 `json:"Top5,omitempty"` // 前5平均, 大于100的取前5%
	Max  float64 `json:"Max,omitempty"`  // 最大值
}

type RoutesScores

type RoutesScores struct {
	Final  bool          `json:"final,omitempty"`
	Round  []model.Round `json:"Round,omitempty"`
	Scores []model.Score `json:"Scores,omitempty"`
}

type ScoreCore

type ScoreCore interface {
	AddScore(AddScoreRequest) error                                               // 添加一条成绩
	RemoveScore(scoreID uint) error                                               // 移除一条成绩
	EndContestScore(contestId uint) error                                         // 结束比赛并统计比赛结果
	GetScoreByPlayerContest(playerId uint, contestId uint) ([]model.Score, error) // 获取玩家在某场比赛的成绩

	AddPreScore(AddPreScoreRequest) error                                                              // 添加一个预录入的成绩
	ProcessPreScore(ProcessPreScoreRequest) error                                                      // 处理一个预录入的成绩
	GetPreScores(page, size int, final Bool) (int64, []model.PreScore, error)                          // 获取预录入的成绩列表(分页), useFinal表示是否使用final筛选字段
	GetPreScoresByPlayer(playerID uint, page, size int, final Bool) (int64, []model.PreScore, error)   // 按玩家获取(分页)
	GetPreScoresByContest(contestID uint, page, size int, final Bool) (int64, []model.PreScore, error) // 按比赛获取(分页)
}

type ScoresByContest

type ScoresByContest struct {
	Contest model.Contest `json:"Contest,omitempty"`
	Scores  []model.Score `json:"Scores,omitempty"`
	Rounds  []model.Round `json:"Rounds,omitempty"`
}

type SorScore

type SorScore struct {
	Player         model.Player `json:"Player,omitempty"`
	SingleRank     int64        `json:"SingleRank,omitempty"`
	SingleCount    int64        `json:"SingleCount,omitempty"`
	SingleProjects int64        `json:"SingleProjects,omitempty"` // 参与项目数
	AvgRank        int64        `json:"AvgRank,omitempty"`
	AvgCount       int64        `json:"AvgCount,omitempty"`
	AvgProjects    int64        `json:"AvgProjects,omitempty"` // 参与项目数
}

type StatisticalCore

type StatisticalCore interface {
	GetRecords(page, size int) (int64, []model.Record, error)                                                        // 获取所有记录(分页)
	GetBestScore() (bestSingle, bestAvg map[model.Project][]model.Score)                                             // 获取所有项目每个人的最佳成绩汇总
	GetBestScoreByTimes(startTime, endTime time.Time) (bestSingle, bestAvg map[model.Project][]model.Score)          // [Time]获取所有项目每个人的最佳成绩汇总
	GetBestScoreByProject(project model.Project) (bestSingle, bestAvg []model.Score)                                 // 获取单项目每个人最佳成绩汇总成绩
	GetAllProjectBestScores() (bestSingle, bestAvg map[model.Project]model.Score)                                    // 获取所有项目最佳成绩
	GetAllProjectBestScoresByTimes(startTime, endTime time.Time) (bestSingle, bestAvg map[model.Project]model.Score) // [Time]获取所有项目最佳成绩
	GetPodiums() []Podiums                                                                                           // 获取领奖台汇总
	GetSor() (single, avg map[model.SorStatisticsKey][]SorScore)                                                     // 获取sor排名汇总
	GetAvgRelativeSor() map[model.SorStatisticsKey]RelativeSor                                                       // 平均相对排位分
	GetRelativeSor() (allPlayerSor map[model.SorStatisticsKey][]RelativeSor)                                         // 相对排位分, 返回所有人的平均排位分,计算方式是用当前最佳成绩为标准, 计算与其差距
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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