Documentation
¶
Index ¶
- Constants
- Variables
- func CanRevertTransfer(origin, dest *PostgresGuild) error
- func CanTransfer(origin, dest *PostgresGuild) error
- func ConstructPsqlConnectURL(addr, username, password string) string
- func EventsToCSV(e []*PostgresGameEvent) string
- func GamesToCSV(g []*PostgresGame) string
- func UsersGamesToCSV(ug []*PostgresUserGame) string
- func UsersToCSV(u []*PostgresUser) string
- type GameStatistics
- type Int16ModeCount
- type PgxIface
- type PostgresBestTeammatePlayerRanking
- type PostgresGame
- type PostgresGameEvent
- type PostgresGuild
- type PostgresOtherPlayerRanking
- type PostgresPlayerRanking
- type PostgresUser
- type PostgresUserActionRanking
- type PostgresUserGame
- type PostgresUserMostFrequentFirstTargetRanking
- type PostgresUserMostFrequentKilledByanking
- type PostgresWorstTeammatePlayerRanking
- type PsqlInterface
- func (psqlInterface *PsqlInterface) AddEvent(event *PostgresGameEvent) error
- func (psqlInterface *PsqlInterface) AddGoldSubServer(origin, dest string) error
- func (psqlInterface *PsqlInterface) AddInitialGame(game *PostgresGame) (uint64, error)
- func (psqlInterface *PsqlInterface) BestTeammateByRole(userID, guildID string, role int16, leaderboardMin int) []*PostgresBestTeammatePlayerRanking
- func (psqlInterface *PsqlInterface) BestTeammateForServerByRole(guildID string, role int16, leaderboardMin int) []*PostgresBestTeammatePlayerRanking
- func (psqlInterface *PsqlInterface) Close()
- func (psqlInterface *PsqlInterface) ColorRankingForPlayerOnServer(userID, guildID string) []*Int16ModeCount
- func (psqlInterface *PsqlInterface) DeleteAllGamesForServer(guildID string) error
- func (psqlInterface *PsqlInterface) DeleteAllGamesForUser(userID string) error
- func (psqlInterface *PsqlInterface) EnsureGuildExists(guildID uint64, guildName string) (*PostgresGuild, error)
- func (psqlInterface *PsqlInterface) EnsureUserExists(userID uint64) (*PostgresUser, error)
- func (psqlInterface *PsqlInterface) GetGame(guildID, connectCode, matchID string) (*PostgresGame, error)
- func (psqlInterface *PsqlInterface) GetGameEvents(matchID string) ([]*PostgresGameEvent, error)
- func (psqlInterface *PsqlInterface) GetGamesEventsForGuild(guildID uint64) ([]*PostgresGameEvent, error)
- func (psqlInterface *PsqlInterface) GetGamesForGuild(guildID uint64) ([]*PostgresGame, error)
- func (psqlInterface *PsqlInterface) GetGuildForDownload(guildID uint64) (*PostgresGuild, error)
- func (psqlInterface *PsqlInterface) GetGuildOrUserPremiumStatus(official bool, dbl *dbl.Client, guildID, userID string) (premium.Tier, int, error)
- func (psqlInterface *PsqlInterface) GetUserByString(userID string) (*PostgresUser, error)
- func (psqlInterface *PsqlInterface) GetUsersForGuild(guildID uint64) ([]*PostgresUser, error)
- func (psqlInterface *PsqlInterface) GetUsersGamesForGuild(guildID uint64) ([]*PostgresUserGame, error)
- func (psqlInterface *PsqlInterface) Init(addr string) error
- func (psqlInterface *PsqlInterface) LoadAndExecFromFile(filepath string) error
- func (psqlInterface *PsqlInterface) NamesRankingForPlayerOnServer(userID, guildID string) []*StringModeCount
- func (psqlInterface *PsqlInterface) NumGamesAsRole(userID string, role int16) int64
- func (psqlInterface *PsqlInterface) NumGamesAsRoleOnServer(userID, guildID string, role int16) int64
- func (psqlInterface *PsqlInterface) NumGamesPlayedByUser(userID string) int64
- func (psqlInterface *PsqlInterface) NumGamesPlayedByUserOnServer(userID, guildID string) int64
- func (psqlInterface *PsqlInterface) NumGamesPlayedOnGuild(guildID string) int64
- func (psqlInterface *PsqlInterface) NumGamesWonAsRoleOnServer(guildID string, role game.GameRole) int64
- func (psqlInterface *PsqlInterface) NumGuildsPlayedInByUser(userID string) int64
- func (psqlInterface *PsqlInterface) NumWins(userID string) int64
- func (psqlInterface *PsqlInterface) NumWinsAsRole(userID string, role int16) int64
- func (psqlInterface *PsqlInterface) NumWinsAsRoleOnServer(userID, guildID string, role int16) int64
- func (psqlInterface *PsqlInterface) NumWinsOnServer(userID, guildID string) int64
- func (psqlInterface *PsqlInterface) OptUserByString(userID string, opt bool) error
- func (psqlInterface *PsqlInterface) OtherPlayersRankingForPlayerOnServer(userID, guildID string) []*PostgresOtherPlayerRanking
- func (psqlInterface *PsqlInterface) RevertPremiumTransfer(original, transferred string) error
- func (psqlInterface *PsqlInterface) TotalGamesRankingForServer(guildID uint64) []*Uint64ModeCount
- func (psqlInterface *PsqlInterface) TotalWinRankingForServer(guildID uint64) []*PostgresPlayerRanking
- func (psqlInterface *PsqlInterface) TotalWinRankingForServerByRole(guildID uint64, role int16) []*PostgresPlayerRanking
- func (psqlInterface *PsqlInterface) TransferPremium(origin, dest string) error
- func (psqlInterface *PsqlInterface) UpdateGameAndPlayers(gameID int64, winType int16, endTime int64, players []*PostgresUserGame) error
- func (psqlInterface *PsqlInterface) UserFrequentFirstTarget(userID, guildID string, action string, leaderboardSize int) []*PostgresUserMostFrequentFirstTargetRanking
- func (psqlInterface *PsqlInterface) UserMostFrequentFirstTargetForServer(guildID string, action string, leaderboardSize int) []*PostgresUserMostFrequentFirstTargetRanking
- func (psqlInterface *PsqlInterface) UserMostFrequentKilledBy(userID, guildID string) []*PostgresUserMostFrequentKilledByanking
- func (psqlInterface *PsqlInterface) UserMostFrequentKilledByServer(guildID string) []*PostgresUserMostFrequentKilledByanking
- func (psqlInterface *PsqlInterface) UserWinByActionAndRole(userdID, guildID string, action string, role int16) []*PostgresUserActionRanking
- func (psqlInterface *PsqlInterface) WorstTeammateByRole(userID, guildID string, role int16, leaderboardMin int) []*PostgresWorstTeammatePlayerRanking
- func (psqlInterface *PsqlInterface) WorstTeammateForServerByRole(guildID string, role int16, leaderboardMin int) []*PostgresWorstTeammatePlayerRanking
- type PsqlParameters
- type SimpleEvent
- type SimpleEventType
- type StringModeCount
- type Uint64ModeCount
Constants ¶
View Source
const ( SecsInADay = 86400 SecsIn12Hrs = SecsInADay / 2 TopGGID = "753795015830011944" )
Variables ¶
View Source
var DiscussCode = fmt.Sprintf("%d", game.DISCUSS)
View Source
var TasksCode = fmt.Sprintf("%d", game.TASKS)
Functions ¶
func CanRevertTransfer ¶ added in v0.3.3
func CanRevertTransfer(origin, dest *PostgresGuild) error
func CanTransfer ¶ added in v0.0.27
func CanTransfer(origin, dest *PostgresGuild) error
CanTransfer determines the set of possible transfers for server premium it does NOT allow for chained transfers! Aka if A -> B, then B cannot transfer to C (nor back to A)
func ConstructPsqlConnectURL ¶
func EventsToCSV ¶ added in v0.4.0
func EventsToCSV(e []*PostgresGameEvent) string
func GamesToCSV ¶ added in v0.4.0
func GamesToCSV(g []*PostgresGame) string
func UsersGamesToCSV ¶ added in v0.4.0
func UsersGamesToCSV(ug []*PostgresUserGame) string
func UsersToCSV ¶ added in v0.4.0
func UsersToCSV(u []*PostgresUser) string
Types ¶
type GameStatistics ¶ added in v0.0.24
type GameStatistics struct { GameDuration time.Duration WinType game.GameResult NumMeetings int NumDeaths int NumVotedOff int NumDisconnects int Events []SimpleEvent }
func StatsFromGameAndEvents ¶ added in v0.0.24
func StatsFromGameAndEvents(pgame *PostgresGame, events []*PostgresGameEvent) GameStatistics
func (*GameStatistics) FormatDurationAndWin ¶ added in v0.0.24
func (stats *GameStatistics) FormatDurationAndWin() string
TODO localize
func (*GameStatistics) ToDiscordEmbed ¶ added in v0.0.24
func (stats *GameStatistics) ToDiscordEmbed(combinedID string, sett *settings.GuildSettings) *discordgo.MessageEmbed
func (*GameStatistics) ToString ¶ added in v0.0.24
func (stats *GameStatistics) ToString() string
type Int16ModeCount ¶ added in v0.0.24
type PgxIface ¶ added in v0.3.0
type PgxIface interface { Begin(context.Context) (pgx.Tx, error) Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error) QueryRow(context.Context, string, ...interface{}) pgx.Row Query(context.Context, string, ...interface{}) (pgx.Rows, error) Ping(context.Context) error Prepare(context.Context, string, string) (*pgconn.StatementDescription, error) }
type PostgresGame ¶
type PostgresGameEvent ¶
type PostgresGuild ¶
type PostgresGuild struct { GuildID uint64 `db:"guild_id"` GuildName string `db:"guild_name"` Premium int16 `db:"premium"` TxTimeUnix *int32 `db:"tx_time_unix"` TransferredTo *uint64 `db:"transferred_to"` InheritsFrom *uint64 `db:"inherits_from"` }
func (*PostgresGuild) ToCSV ¶ added in v0.4.0
func (g *PostgresGuild) ToCSV() string
type PostgresPlayerRanking ¶
type PostgresUser ¶
type PostgresUserGame ¶
type PsqlInterface ¶
func (*PsqlInterface) AddEvent ¶
func (psqlInterface *PsqlInterface) AddEvent(event *PostgresGameEvent) error
func (*PsqlInterface) AddGoldSubServer ¶ added in v0.0.30
func (psqlInterface *PsqlInterface) AddGoldSubServer(origin, dest string) error
func (*PsqlInterface) AddInitialGame ¶
func (psqlInterface *PsqlInterface) AddInitialGame(game *PostgresGame) (uint64, error)
func (*PsqlInterface) BestTeammateByRole ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) BestTeammateByRole(userID, guildID string, role int16, leaderboardMin int) []*PostgresBestTeammatePlayerRanking
func (*PsqlInterface) BestTeammateForServerByRole ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) BestTeammateForServerByRole(guildID string, role int16, leaderboardMin int) []*PostgresBestTeammatePlayerRanking
func (*PsqlInterface) Close ¶
func (psqlInterface *PsqlInterface) Close()
func (*PsqlInterface) ColorRankingForPlayerOnServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) ColorRankingForPlayerOnServer(userID, guildID string) []*Int16ModeCount
func (psqlInterface *PsqlInterface) ColorRankingForPlayer(userID string) []*Int16ModeCount { r := []*Int16ModeCount{} err := pgxscan.Select(context.Background(), psqlInterface.Pool, &r, "SELECT count(*),mode() within GROUP (ORDER BY player_color) AS mode FROM users_games WHERE user_id=$1 GROUP BY player_color ORDER BY count desc;", userID) if err != nil { log.Println(err) } return r }
func (*PsqlInterface) DeleteAllGamesForServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) DeleteAllGamesForServer(guildID string) error
func (*PsqlInterface) DeleteAllGamesForUser ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) DeleteAllGamesForUser(userID string) error
func (*PsqlInterface) EnsureGuildExists ¶
func (psqlInterface *PsqlInterface) EnsureGuildExists(guildID uint64, guildName string) (*PostgresGuild, error)
func (*PsqlInterface) EnsureUserExists ¶
func (psqlInterface *PsqlInterface) EnsureUserExists(userID uint64) (*PostgresUser, error)
func (*PsqlInterface) GetGame ¶
func (psqlInterface *PsqlInterface) GetGame(guildID, connectCode, matchID string) (*PostgresGame, error)
func (*PsqlInterface) GetGameEvents ¶
func (psqlInterface *PsqlInterface) GetGameEvents(matchID string) ([]*PostgresGameEvent, error)
func (*PsqlInterface) GetGamesEventsForGuild ¶ added in v0.4.0
func (psqlInterface *PsqlInterface) GetGamesEventsForGuild(guildID uint64) ([]*PostgresGameEvent, error)
func (*PsqlInterface) GetGamesForGuild ¶ added in v0.4.0
func (psqlInterface *PsqlInterface) GetGamesForGuild(guildID uint64) ([]*PostgresGame, error)
func (*PsqlInterface) GetGuildForDownload ¶ added in v0.4.0
func (psqlInterface *PsqlInterface) GetGuildForDownload(guildID uint64) (*PostgresGuild, error)
func (*PsqlInterface) GetGuildOrUserPremiumStatus ¶ added in v0.2.0
func (*PsqlInterface) GetUserByString ¶
func (psqlInterface *PsqlInterface) GetUserByString(userID string) (*PostgresUser, error)
func (*PsqlInterface) GetUsersForGuild ¶ added in v0.4.0
func (psqlInterface *PsqlInterface) GetUsersForGuild(guildID uint64) ([]*PostgresUser, error)
func (*PsqlInterface) GetUsersGamesForGuild ¶ added in v0.4.0
func (psqlInterface *PsqlInterface) GetUsersGamesForGuild(guildID uint64) ([]*PostgresUserGame, error)
func (*PsqlInterface) Init ¶
func (psqlInterface *PsqlInterface) Init(addr string) error
func (*PsqlInterface) LoadAndExecFromFile ¶
func (psqlInterface *PsqlInterface) LoadAndExecFromFile(filepath string) error
func (*PsqlInterface) NamesRankingForPlayerOnServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NamesRankingForPlayerOnServer(userID, guildID string) []*StringModeCount
func (*PsqlInterface) NumGamesAsRole ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumGamesAsRole(userID string, role int16) int64
func (*PsqlInterface) NumGamesAsRoleOnServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumGamesAsRoleOnServer(userID, guildID string, role int16) int64
func (*PsqlInterface) NumGamesPlayedByUser ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumGamesPlayedByUser(userID string) int64
func (*PsqlInterface) NumGamesPlayedByUserOnServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumGamesPlayedByUserOnServer(userID, guildID string) int64
func (*PsqlInterface) NumGamesPlayedOnGuild ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumGamesPlayedOnGuild(guildID string) int64
func (*PsqlInterface) NumGamesWonAsRoleOnServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumGamesWonAsRoleOnServer(guildID string, role game.GameRole) int64
func (*PsqlInterface) NumGuildsPlayedInByUser ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumGuildsPlayedInByUser(userID string) int64
func (*PsqlInterface) NumWins ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumWins(userID string) int64
func (*PsqlInterface) NumWinsAsRole ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumWinsAsRole(userID string, role int16) int64
func (*PsqlInterface) NumWinsAsRoleOnServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumWinsAsRoleOnServer(userID, guildID string, role int16) int64
func (*PsqlInterface) NumWinsOnServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) NumWinsOnServer(userID, guildID string) int64
func (*PsqlInterface) OptUserByString ¶
func (psqlInterface *PsqlInterface) OptUserByString(userID string, opt bool) error
func (*PsqlInterface) OtherPlayersRankingForPlayerOnServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) OtherPlayersRankingForPlayerOnServer(userID, guildID string) []*PostgresOtherPlayerRanking
func (*PsqlInterface) RevertPremiumTransfer ¶ added in v0.3.3
func (psqlInterface *PsqlInterface) RevertPremiumTransfer(original, transferred string) error
func (*PsqlInterface) TotalGamesRankingForServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) TotalGamesRankingForServer(guildID uint64) []*Uint64ModeCount
func (*PsqlInterface) TotalWinRankingForServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) TotalWinRankingForServer(guildID uint64) []*PostgresPlayerRanking
func (*PsqlInterface) TotalWinRankingForServerByRole ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) TotalWinRankingForServerByRole(guildID uint64, role int16) []*PostgresPlayerRanking
func (*PsqlInterface) TransferPremium ¶ added in v0.0.27
func (psqlInterface *PsqlInterface) TransferPremium(origin, dest string) error
func (*PsqlInterface) UpdateGameAndPlayers ¶
func (psqlInterface *PsqlInterface) UpdateGameAndPlayers(gameID int64, winType int16, endTime int64, players []*PostgresUserGame) error
make sure to call the relevant "ensure" methods before this one...
func (*PsqlInterface) UserFrequentFirstTarget ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) UserFrequentFirstTarget(userID, guildID string, action string, leaderboardSize int) []*PostgresUserMostFrequentFirstTargetRanking
func (*PsqlInterface) UserMostFrequentFirstTargetForServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) UserMostFrequentFirstTargetForServer(guildID string, action string, leaderboardSize int) []*PostgresUserMostFrequentFirstTargetRanking
func (*PsqlInterface) UserMostFrequentKilledBy ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) UserMostFrequentKilledBy(userID, guildID string) []*PostgresUserMostFrequentKilledByanking
func (*PsqlInterface) UserMostFrequentKilledByServer ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) UserMostFrequentKilledByServer(guildID string) []*PostgresUserMostFrequentKilledByanking
func (*PsqlInterface) UserWinByActionAndRole ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) UserWinByActionAndRole(userdID, guildID string, action string, role int16) []*PostgresUserActionRanking
func (*PsqlInterface) WorstTeammateByRole ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) WorstTeammateByRole(userID, guildID string, role int16, leaderboardMin int) []*PostgresWorstTeammatePlayerRanking
func (*PsqlInterface) WorstTeammateForServerByRole ¶ added in v0.0.24
func (psqlInterface *PsqlInterface) WorstTeammateForServerByRole(guildID string, role int16, leaderboardMin int) []*PostgresWorstTeammatePlayerRanking
type PsqlParameters ¶
type SimpleEvent ¶ added in v0.0.24
type SimpleEvent struct { EventType SimpleEventType EventTimeOffset time.Duration Data string }
type SimpleEventType ¶ added in v0.0.24
type SimpleEventType int
const ( Tasks SimpleEventType = iota Discuss PlayerDeath PlayerDisconnect )
type StringModeCount ¶ added in v0.0.24
type Uint64ModeCount ¶ added in v0.0.24
Click to show internal directories.
Click to hide internal directories.