model

package
v0.0.0-...-ac6c325 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2016 License: MIT Imports: 15 Imported by: 4

Documentation

Index

Constants

View Source
const (
	PermissionView = iota
	PermissionEdit
)
View Source
const (
	RegionNA   = "na"
	RegionEUW  = "euw"
	RegionEUNE = "eune"
)

Variables

View Source
var RiotApiRateLimiter = DistributedRateLimiter{
	Name:   "riot-rest-api",
	Limits: RiotDevRateLimits,
}
View Source
var RiotDevRateLimits = []RateLimit{
	RateLimit{5, 10},
	RateLimit{250, 10 * 60},
}

Functions

func AclCan

func AclCan(
	c appengine.Context,
	requestor *datastore.Key,
	perm Permission,
	resource *datastore.Key) (bool, error)

func AclFindAll

func AclFindAll(
	c appengine.Context,
	requestor *datastore.Key,
	resourceKind string,
	perm Permission) ([]*datastore.Key, error)

func AclGrant

func AclGrant(
	c appengine.Context,
	requestor *datastore.Key,
	resource *datastore.Key,
	perm Permission) error

func AclRevoke

func AclRevoke(
	c appengine.Context,
	requestor *datastore.Key,
	resource *datastore.Key,
	perm Permission) error

func AddGameTag

func AddGameTag(
	c appengine.Context,
	userAcls *RequestorAclCache,
	leagueKey *datastore.Key,
	gameKey *datastore.Key,
	tag string,
	reason string) error

func AddUnverifiedSummoner

func AddUnverifiedSummoner(
	c appengine.Context,
	userKey *datastore.Key,
	region string,
	summoner string) error

func AddUserGameTag

func AddUserGameTag(
	c appengine.Context,
	userKey *datastore.Key,
	leagueKey *datastore.Key,
	gameKey *datastore.Key,
	tag string) error

func CreateScheduledMatch

func CreateScheduledMatch(
	c appengine.Context,
	userAcls *RequestorAclCache,
	league *League,
	leagueKey *datastore.Key,
	match *ScheduledMatch) error

Creates a scheduled match.

func DecodeKeyShort

func DecodeKeyShort(
	c appengine.Context,
	kind string,
	encodedKey string,
	parentKey *datastore.Key) (*datastore.Key, error)

func DelGameTag

func DelGameTag(
	c appengine.Context,
	userAcls *RequestorAclCache,
	leagueKey *datastore.Key,
	gameKey *datastore.Key,
	tag string) error

func DelUserGameTag

func DelUserGameTag(
	c appengine.Context,
	userKey *datastore.Key,
	leagueKey *datastore.Key,
	gameKey *datastore.Key,
	tag string) error

func EncodeKeyShort

func EncodeKeyShort(k *datastore.Key) string

func EnsureGameExists

func EnsureGameExists(
	c appengine.Context,
	region string,
	gameKey *datastore.Key,
	riotSummonerId int64,
	dto *riot.GameDto) error

func GameUri

func GameUri(gameKey *datastore.Key) string

func GetGroupsForUser

func GetGroupsForUser(
	c appengine.Context, userKey *datastore.Key) ([]*Group, []*GroupMembership, error)

func GroupAddMember

func GroupAddMember(
	c appengine.Context, groupKey *datastore.Key, userKey *datastore.Key, owner bool) error

func GroupAddProposedMember

func GroupAddProposedMember(
	c appengine.Context, groupKey *datastore.Key, userKey *datastore.Key, notes string) error

func GroupById

func GroupById(
	c appengine.Context,
	userKey *datastore.Key,
	groupId string) (*Group, *datastore.Key, *GroupMembership, error)

func GroupByKey

func GroupByKey(
	c appengine.Context,
	groupKey *datastore.Key,
	userKey *datastore.Key) (*Group, *GroupMembership, error)

func GroupDelMember

func GroupDelMember(
	c appengine.Context, groupKey *datastore.Key, userKey *datastore.Key) error

func GroupId

func GroupId(groupKey *datastore.Key) string

func GroupKeyById

func GroupKeyById(c appengine.Context, groupId string) (*datastore.Key, error)

func GroupRootKey

func GroupRootKey(c appengine.Context) *datastore.Key

func GroupUri

func GroupUri(groupKey *datastore.Key) string

func KeyForGame

func KeyForGame(c appengine.Context, region string, riotGameId int64) *datastore.Key

func KeyForGameId

func KeyForGameId(c appengine.Context, gameId string) *datastore.Key

func KeyForPlayer

func KeyForPlayer(c appengine.Context, region string, riotSummonerId int64) *datastore.Key

func KeyForPlayerGameStats

func KeyForPlayerGameStats(c appengine.Context, game *Game, player *Player) *datastore.Key

func KeyForPlayerGameStatsId

func KeyForPlayerGameStatsId(
	c appengine.Context, gameId string, playerId string) *datastore.Key

func LeagueAddGameByTeam

func LeagueAddGameByTeam(
	c appengine.Context,
	leagueKey *datastore.Key,
	gameByTeam *GameByTeam) error

func LeagueTeamUri

func LeagueTeamUri(leagueKey *datastore.Key, teamKey *datastore.Key) string

func LeagueUri

func LeagueUri(leagueKey *datastore.Key) string

func MakeGameId

func MakeGameId(region string, riotId int64) string

func MakePlayerId

func MakePlayerId(region string, riotSummonerId int64) string

func MatchId

func MatchId(matchKey *datastore.Key) string

func RegionForGameId

func RegionForGameId(id string) string

func SetPrimarySummoner

func SetPrimarySummoner(
	c appengine.Context,
	userKey *datastore.Key,
	player *Player,
	playerKey *datastore.Key) error

func SetRiotApiKey

func SetRiotApiKey(c appengine.Context, apikey string) error

func SplitPlayerKey

func SplitPlayerKey(key *datastore.Key) (string, int64, error)

func TeamAddPlayer

func TeamAddPlayer(
	c appengine.Context,
	userAcls *RequestorAclCache,
	league *League,
	leagueKey *datastore.Key,
	teamKey *datastore.Key,
	playerKey *datastore.Key) error

func TeamDelPlayer

func TeamDelPlayer(
	c appengine.Context,
	userAcls *RequestorAclCache,
	league *League,
	leagueKey *datastore.Key,
	teamKey *datastore.Key,
	playerKey *datastore.Key) error

func VerifySummoner

func VerifySummoner(
	c appengine.Context,
	userKey *datastore.Key,
	playerKey *datastore.Key,
	player *Player) error

Types

type Acl

type Acl struct {
	// User key or Group key.
	Requestor *datastore.Key

	// The key of the protected resource.
	Resource *datastore.Key

	// The entity type of the resource key.
	ResourceKind string

	Permission Permission
}

Ancestor: GroupRootKey

type CollectiveGameStats

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

func (*CollectiveGameStats) Add

func (c *CollectiveGameStats) Add(
	gameId string, riotSummonerId int64, stats *riot.GameDto)

Adds a player's stats to the collective stats and creates entries with nil stats for players in this game that have not been added to the map yet.

func (*CollectiveGameStats) DebugString

func (s *CollectiveGameStats) DebugString() string

func (*CollectiveGameStats) FilterToGamesWithPlayersAtLeast

func (s *CollectiveGameStats) FilterToGamesWithPlayersAtLeast(n int)

Filters the stats collection to games that have at least n players from the specified list appearing on the same team.

func (*CollectiveGameStats) ForEachGame

func (s *CollectiveGameStats) ForEachGame(fn func(string, *GameStats, int64, *riot.GameDto))

Calls the provided function once for each game with a sample player's stat for that game.

func (*CollectiveGameStats) ForEachStat

func (s *CollectiveGameStats) ForEachStat(fn func(string, int64, *riot.GameDto))

Calls the provided function once for each player's stat.

func (*CollectiveGameStats) Lookup

func (c *CollectiveGameStats) Lookup(gameId string, riotSummonerId int64) *riot.GameDto

func (*CollectiveGameStats) Size

func (s *CollectiveGameStats) Size() int

type DistributedRateLimiter

type DistributedRateLimiter struct {
	Name   string
	Limits []RateLimit
}

func (*DistributedRateLimiter) Consume

func (r *DistributedRateLimiter) Consume(
	c appengine.Context,
	events int) error

Blocks for up to 1 minute.

func (*DistributedRateLimiter) DebugStr

func (DistributedRateLimiter) Init

Creates a new DistributedRateLimiter that allows events according to the specified limits (or re-initializes the limits of an existing rate limiter with the same name).

func (*DistributedRateLimiter) TryConsume

func (r *DistributedRateLimiter) TryConsume(c appengine.Context, events int) error

Consumes tokens from the rate limiter if nil is returned. Otherwise an error is returned describing why tokens could not be consumed.

type DistributedRateLimiterEntity

type DistributedRateLimiterEntity struct {
	// Counts of the total number of requests accepted.
	AcceptCount int64

	// Internal buckets.
	Buckets []TokenBucket
}

An opaque type for managing distributed rate limits with the appengine datastore. Use its methods to interact with it.

type ErrNotAuthorized

type ErrNotAuthorized struct {
	Permission Permission
	Resource   *datastore.Key
}

func (ErrNotAuthorized) Error

func (e ErrNotAuthorized) Error() string

type ErrRateLimitExceeded

type ErrRateLimitExceeded struct {
	RateLimit *DistributedRateLimiter
	Debug     error
}

func (ErrRateLimitExceeded) Error

func (e ErrRateLimitExceeded) Error() string

type ErrorNoRiotApiKey

type ErrorNoRiotApiKey struct{}

func (ErrorNoRiotApiKey) Error

func (e ErrorNoRiotApiKey) Error() string

type Game

type Game struct {
	Region string
	RiotId int64

	// Fields below are populated from riot player stats.
	HasRiotData   bool
	StartDateTime time.Time
	MapId         int
	GameMode      string
	GameType      string
	SubType       string
	Players       []riot.PlayerDto
	Invalid       bool
}

func GameById

func GameById(
	c appengine.Context,
	gameId string) (*Game, *datastore.Key, error)

func GetOrCreateGame

func GetOrCreateGame(
	c appengine.Context, region string, riotGameId int64) (*Game, *datastore.Key, error)

func GetPlayerGameStats

func GetPlayerGameStats(
	c appengine.Context,
	gameKey *datastore.Key,
	playerKey *datastore.Key,
	getKeysOnly bool) (*Game, *datastore.Key, error)

func (*Game) FormatGameType

func (game *Game) FormatGameType() string

func (*Game) FormatTime

func (game *Game) FormatTime() string

func (*Game) Id

func (g *Game) Id() string

func (*Game) Key

func (g *Game) Key(c appengine.Context) *datastore.Key

func (*Game) Uri

func (g *Game) Uri() string

type GameByTeam

type GameByTeam struct {
	GameKey  *datastore.Key
	TeamKey  *datastore.Key
	DateTime time.Time

	// Contains {riot.BlueTeamId, riot.PurpleTeamId} if that team contained at least 3
	// members of the team.
	RiotTeamIds []int
}

An association between games and teams.

Specifically the games containing at least 3 members of the league-team on the same in-game team.

Ancestor: League

func (*GameByTeam) IsOnBlue

func (g *GameByTeam) IsOnBlue() bool

func (*GameByTeam) IsOnPurple

func (g *GameByTeam) IsOnPurple() bool

type GameByTime

type GameByTime []*Game

func (GameByTime) Len

func (a GameByTime) Len() int

func (GameByTime) Less

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

func (GameByTime) Swap

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

type GameInfo

type GameInfo struct {
	Game *Game

	// Non-empty when viewed in the context of a league.
	LeagueId string

	BlueTeam   *GameTeamInfo
	PurpleTeam *GameTeamInfo

	// Aliases for BlueTeam/PurpleTeam based on which side has more summoners that are players
	// of the team someone is inspecting in the application.
	ThisTeam  *GameTeamInfo
	OtherTeam *GameTeamInfo
	// contains filtered or unexported fields
}

func GetGameInfo

func GetGameInfo(
	c appengine.Context,
	playerCache *PlayerCache,
	game *Game) (*GameInfo, []error)

func NewGameInfo

func NewGameInfo() *GameInfo

func TeamRecentGameInfo

func TeamRecentGameInfo(
	c appengine.Context,
	userAcls *RequestorAclCache,
	n int,
	playerCache *PlayerCache,
	league *League,
	leagueKey *datastore.Key,
	teamKey *datastore.Key) ([]*GameInfo, []error)

Note that sometimes partial results are returned even if there is an error.

func (*GameInfo) AddAppTeamPlayer

func (ginfo *GameInfo) AddAppTeamPlayer(p *Player)

When this game was looked up in the context of a team registered with the application, this adds that player to the GameInfo.

func (*GameInfo) AddGamePlayer

func (ginfo *GameInfo) AddGamePlayer(
	teamId int, p *Player, championId int, pstats *PlayerGameStats)

Adds a player and their in-game-stats to the GameInfo.

type GamePlayerInfo

type GamePlayerInfo struct {
	Player     *Player
	ChampionId int
}

func NewGamePlayerInfo

func NewGamePlayerInfo(p *Player, championId int) *GamePlayerInfo

type GamePlayerStatsInfo

type GamePlayerStatsInfo struct {
	Saved        bool
	NotAvailable bool
	IsOnAppTeam  bool
	Player       *Player
	Stats        *PlayerGameStats
}

func NewGamePlayerStatsInfo

func NewGamePlayerStatsInfo(
	player *Player, stats *PlayerGameStats, isOnAppTeam bool) *GamePlayerStatsInfo

type GameStats

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

func (*GameStats) AddStats

func (g *GameStats) AddStats(riotSummonerId int64, stats *riot.GameDto)

func (*GameStats) GetTeamsWithCountAtLeast

func (g *GameStats) GetTeamsWithCountAtLeast(target int) []int

func (*GameStats) IncrementTeamCount

func (g *GameStats) IncrementTeamCount(riotTeamId int)

func (*GameStats) Lookup

func (g *GameStats) Lookup(riotSummonerId int64) *riot.GameDto

type GameTag

type GameTag struct {
	Game   *datastore.Key
	Tag    string
	Reason string
}

A tag for a game added by the system.

Ancestor: League

func GetGameTags

func GetGameTags(
	c appengine.Context,
	userAcls *RequestorAclCache,
	leagueKey *datastore.Key,
	gameKey *datastore.Key) ([]*GameTag, []*datastore.Key, error)

type GameTags

type GameTags struct {
	GameKey *datastore.Key
	Tag     string
}

An associate between games and tags. A game can have multiple tags.

Ancestor: League

type GameTeamInfo

type GameTeamInfo struct {
	IsBlueTeam   bool
	IsPurpleTeam bool
	Players      []*GamePlayerInfo
	PlayerStats  []*GamePlayerStatsInfo

	// stats
	IsWinner        bool
	ChampionsKilled int
	NumDeaths       int
	Assists         int
	GoldEarned      int
}

func NewGameTeamInfo

func NewGameTeamInfo() *GameTeamInfo

type Group

type Group struct {
	Name string
}

func CreateGroup

func CreateGroup(c appengine.Context, name string) (*Group, *datastore.Key, error)

Creates a new group with the current user as the owner.

type GroupMembership

type GroupMembership struct {
	GroupKey *datastore.Key
	UserKey  *datastore.Key
	Owner    bool
}

func GetGroupMemberships

func GetGroupMemberships(
	c appengine.Context, groupKey *datastore.Key) ([]*GroupMembership, error)

type GroupRoot

type GroupRoot struct{}

Root entity for all groups and acls.

type KeysOnlyOption

type KeysOnlyOption bool
const (
	KeysOnly        KeysOnlyOption = true
	KeysAndEntities                = false
)

type League

type League struct {
	// The name of the league. Not necessarily unique.
	Name string

	// The Riot server region for this league. Defaults to RegionNA.
	Region string

	// The datastore key for the User who owns this league.
	Owner *datastore.Key
}

Leagues are identified by their key.

func CreateLeague

func CreateLeague(c appengine.Context, name string) (*League, *datastore.Key, error)

func LeagueById

func LeagueById(
	c appengine.Context,
	leagueId string) (*League, *datastore.Key, error)

func LeaguesForUser

func LeaguesForUser(
	c appengine.Context, userAcls *RequestorAclCache) ([]*League, []*datastore.Key, error)

type MatchResult

type MatchResult struct {
	ScheduledMatch *datastore.Key
	Team           *datastore.Key
	Points         int
	ManualResult   bool
}

type Permission

type Permission int

func AllPermissions

func AllPermissions() []Permission

func (Permission) String

func (p Permission) String() string

type Player

type Player struct {
	// The current summoner name for this player.
	Summoner string

	// This is the region for the given player.
	Region string

	// Summoner id as per Riot API.
	RiotId int64

	// This player's in game level.
	Level int

	LastUpdated time.Time
}

("%s-%s", Region, RiotId) is the key for a player.

func GetOrCreatePlayerByRiotId

func GetOrCreatePlayerByRiotId(
	c appengine.Context,
	region string,
	riotId int64) (*Player, *datastore.Key, error)

func GetOrCreatePlayerBySummoner

func GetOrCreatePlayerBySummoner(
	c appengine.Context,
	region string,
	summoner string) (*Player, *datastore.Key, error)

func GetPlayerByRiotIdOrStub

func GetPlayerByRiotIdOrStub(
	c appengine.Context,
	region string,
	riotId int64) (*Player, *datastore.Key, error)

func TeamAllPlayers

func TeamAllPlayers(
	c appengine.Context,
	userAcls *RequestorAclCache,
	league *League,
	leagueKey *datastore.Key,
	teamKey *datastore.Key,
	keysOnly KeysOnlyOption) ([]*Player, []*datastore.Key, error)

func (*Player) Id

func (p *Player) Id() string

func (*Player) Uri

func (p *Player) Uri() string

type PlayerCache

type PlayerCache struct {
	Region string
	// contains filtered or unexported fields
}

Caches player data within a region.

func NewPlayerCache

func NewPlayerCache(c appengine.Context, region string) *PlayerCache

func (*PlayerCache) Add

func (cache *PlayerCache) Add(p *Player)

func (*PlayerCache) ById

func (cache *PlayerCache) ById(riotId int64) (*Player, error)

func (*PlayerCache) BySummoner

func (cache *PlayerCache) BySummoner(summoner string) (*Player, error)

type PlayerGameStats

type PlayerGameStats struct {
	GameKey   *datastore.Key
	PlayerKey *datastore.Key

	// Stats for games that have expired out of recent player history on the Riot side
	// before we get around to looking for them may be lost forever. This field is set
	// to true if we know the game stats are no longer available and we don't have a
	// copy yet.
	NotAvailable bool

	// Set to true when we have captured the stats for this player and game already.
	Saved bool

	// The raw stats fetched from riot.
	RiotData riot.RawStatsDto
}

The tuple (GameKey, PlayerKey) are unique per entity.

type PlayerScoring

type PlayerScoring interface {
	Score(match *ScheduledMatch, player *Player, games []*GameInfo) Score
}

A PlayerScoring is used to take a chronological series of games and compute how many points a player has earned for those results. Results may be negative.

type PlayersBySummoner

type PlayersBySummoner []*Player

sort.Interface for []*Player

func (PlayersBySummoner) Len

func (a PlayersBySummoner) Len() int

func (PlayersBySummoner) Less

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

func (PlayersBySummoner) Swap

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

type ProposedGroupMembership

type ProposedGroupMembership struct {
	GroupKey *datastore.Key
	UserKey  *datastore.Key
	Notes    string
}

func GetProposedGroupMemberships

func GetProposedGroupMemberships(
	c appengine.Context, groupKey *datastore.Key) ([]*ProposedGroupMembership, error)

type RateLimit

type RateLimit struct {
	MaxEvents       int
	IntervalSeconds int
}

Describes a rate limit that permits MaxEvents in the last IntervalSeconds. Ex: RateLimit{10, 100} would indicate 10 events per 100 seconds.

type RequestorAclCache

type RequestorAclCache struct {
	UserKey        *datastore.Key
	EncodedUserKey string
	Groups         map[string]*Group
	GroupKeys      map[string]*datastore.Key
	// contains filtered or unexported fields
}

func NewRequestorAclCache

func NewRequestorAclCache(userKey *datastore.Key) *RequestorAclCache

func (*RequestorAclCache) Can

func (req *RequestorAclCache) Can(
	c appengine.Context, perm Permission, resKey *datastore.Key) error

func (*RequestorAclCache) FindAll

func (req *RequestorAclCache) FindAll(
	c appengine.Context, resourceKind string, perm Permission) ([]*datastore.Key, error)

func (*RequestorAclCache) PermissionMapFor

func (req *RequestorAclCache) PermissionMapFor(
	c appengine.Context,
	resKey *datastore.Key) ([]*Group, []*datastore.Key, []map[Permission]bool, error)

For all the groups this user belongs to, returns a permission map for the given resource.

type ResourceAclCache

type ResourceAclCache struct {
	ResourceKey             *datastore.Key
	EncodedResourceKey      string
	Permission              Permission
	AuthorizedRequestorKeys map[string]*datastore.Key
}

func NewResourceAclCache

func NewResourceAclCache(resourceKey *datastore.Key, perm Permission) *ResourceAclCache

func (*ResourceAclCache) IsAuthorizedRequestor

func (res *ResourceAclCache) IsAuthorizedRequestor(req *datastore.Key) bool

type RiotApiKey

type RiotApiKey struct {
	Key string
}

func GetRiotApiKey

func GetRiotApiKey(c appengine.Context) (*RiotApiKey, error)

type ScheduledMatch

type ScheduledMatch struct {
	// A brief "one-line description" of the match.
	// Example: "Summoner's Rift Draft (Best of 1)"
	Summary string

	// A more detailed description of the match.
	Description string

	// The primary tag used to group this with other matches.
	// Example: "Week 1"
	PrimaryTag string

	// The teams involved in the match.
	TeamKeys []*datastore.Key

	// The number of games in the match. Zero or less means "no limit".
	NumGames int

	// The official suggested date(time) of the match.
	OfficialDatetime time.Time

	// The earliest the match should be played. This is not enforced.
	DateEarliest time.Time

	// The latest the match should be played. This is not enforced.
	DateLatest time.Time
}

A scheduled match between two teams.

Ancestor: League

func (*ScheduledMatch) AwayTeam

func (m *ScheduledMatch) AwayTeam() *datastore.Key

func (*ScheduledMatch) HomeTeam

func (m *ScheduledMatch) HomeTeam() *datastore.Key

type Score

type Score struct {
	// The number of points earned.
	Points int
	// True if the score will not change if additional games are played.
	IsFinal bool
}

type SummonerData

type SummonerData struct {
	Player   *Player
	Verified bool
	Token    string
}

func GetSummonerDatas

func GetSummonerDatas(c appengine.Context, userKey *datastore.Key) ([]*SummonerData, error)

type Team

type Team struct {
	Name string
}

Teams are identified by their datastore.Key.

Ancestor: League

func LeagueAddTeam

func LeagueAddTeam(
	c appengine.Context,
	userAcls *RequestorAclCache,
	leagueId string,
	teamName string) (*Team, *datastore.Key, error)

func LeagueAllTeams

func LeagueAllTeams(
	c appengine.Context,
	userAcls *RequestorAclCache,
	league *League,
	leagueKey *datastore.Key) ([]*Team, []*datastore.Key, error)

func TeamById

func TeamById(
	c appengine.Context,
	userAcls *RequestorAclCache,
	league *League,
	leagueKey *datastore.Key,
	teamId string) (*Team, *datastore.Key, error)

type TeamInfo

type TeamInfo struct {
	Name string
	Id   string
	Uri  string
}

Various accumulated data about a team. Not directly stored in datastore.

type TeamMembership

type TeamMembership struct {
	TeamKey   *datastore.Key
	PlayerKey *datastore.Key
}

A table associating summoners to teams. Summoners may be on more than one team per league. Teams may have any number of summoners.

Ancestor: League

type TeamScoring

type TeamScoring interface {
	Score(match *ScheduledMatch, games []*GameInfo) Score
}

A TeamScoring is used to take a chronological series of games and compute how many points a team has earned for those results. Results may be negative.

type TeamScoringType

type TeamScoringType int

A list of supported scoring algorithms for matches.

In the descriptions below, let

M := The number of games in the match (or if the length is unbounded, the number of games played),
G := The list of games played,
S := The first M games of G,
T := The team of interest.
const (
	// BestOfSeries
	// ------------
	// Points
	//   2 points: T wins a majority of games in S
	//   1 point : T wins exactly M/2 of games in S (if M is even)
	//   0 points: otherwise
	//
	// IsFinal
	//   true : at least M games have been played || T wins or loses a majority of games in S
	//   false: otherwise
	BestOfSeries TeamScoringType = 0

	// ThreeOneZeroSeries
	// ------------------
	// Points
	// 3 points: T wins a majority of games in S
	// 1 point : T wins exactly M/2 of games in S (if M is even)
	// 0 points: otherwise
	//
	// IsFinal
	// true : at least M games have been played
	// false: otherwise
	ThreeOneZeroSeries TeamScoringType = 1
)

type TokenBucket

type TokenBucket struct {
	Limit RateLimit

	// The number of tokens in the bucket at LastCheckTime.
	Tokens float64

	// Tracks the last time this token bucket was processed so that we can
	// optimize adding tokens to the bucket each update instead of every
	// Rate seconds. Time is in UTC.
	LastCheckTime time.Time
}

func (*TokenBucket) AddTokens

func (b *TokenBucket) AddTokens(t time.Time)

func (*TokenBucket) SetLimit

func (b *TokenBucket) SetLimit(limit RateLimit)

If the provided limits are the same as the existing limits this is a no-op. Otherwise the limits are set to the new limits and all tokens are removed from the bucket.

type UnverifiedSummoner

type UnverifiedSummoner struct {
	User       *datastore.Key
	Player     *datastore.Key
	Token      string
	CreateTime time.Time
}

Key: ("%s:%s", User.StringID(), Player.StringID())

type User

type User struct {
	Email string

	// Empty if no verified summoner.
	DisplayName string
}

func GetUser

func GetUser(c appengine.Context) (*User, *datastore.Key, error)

Fetches the user from the datastore if it exists, otherwise puts a new user into the datastore and returns it.

func GetUserByEmail

func GetUserByEmail(c appengine.Context, email string) (*User, *datastore.Key, error)

func GetUserByKey

func GetUserByKey(c appengine.Context, userKey *datastore.Key) (*User, error)

type UserGameTag

type UserGameTag struct {
	User *datastore.Key
	Game *datastore.Key
	Tag  string
}

A tag for a game added by a user.

Ancestor: League

func GetUserGameTags

func GetUserGameTags(
	c appengine.Context,
	userKey *datastore.Key,
	leagueKey *datastore.Key,
	gameKey *datastore.Key) ([]*UserGameTag, []*datastore.Key, error)

type VerifiedSummoner

type VerifiedSummoner struct {
	User   *datastore.Key
	Player *datastore.Key
}

Key: ("%s:%s", User.StringID(), Player.StringID())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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