|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- // NGnius 2020-01-30
-
- package main
-
- import (
- "strconv"
- "time"
- )
-
- // Board a leaderboard
- type Board struct {
- ID int64
- Entries []Entry
- Name string
- }
-
- // Entry an entry in a leaderboard
- type Entry struct {
- ID int64
- Rank int64
- Score int64
- PlayerName string
- PlayerURL string
- }
-
- // Player a player
- type Player struct {
- ID int64
- Name string
- Entries []Entry
- }
-
- // URL get the player's URL
- func (p *Player) URL() string {
- return "/player/" + strconv.Itoa(int(p.ID))
- }
-
- // Result a query result
- type Result struct {
- Items []interface{}
- Elapsed int64
- Count int
- Query string
- URL string
- Start time.Time
- }
-
- // NewResult build a query struct
- func NewResult(q string, url string) (r Result) {
- r.Start = time.Now()
- r.Query = q
- r.URL = url
- return
- }
-
- // Complete finish the result
- func (r *Result) Complete() {
- r.Count = len(r.Items)
- r.Elapsed = time.Since(r.Start).Milliseconds()
- }
|