-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
map vote stats added, more detailed map stats in UI
- Loading branch information
1 parent
78c0a3c
commit 44ac2f2
Showing
12 changed files
with
163 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
. "github.com/Harrison-Miller/kagstats/common/models" | ||
. "github.com/Harrison-Miller/kagstats/indexer" | ||
) | ||
|
||
type MapVoteStatsIndexer struct { | ||
} | ||
|
||
func (i *MapVoteStatsIndexer) Name() string { | ||
return "map_vote_stats" | ||
} | ||
|
||
func (i *MapVoteStatsIndexer) Version() int { | ||
return 1 | ||
} | ||
|
||
func (i *MapVoteStatsIndexer) Keys() []IndexKey { | ||
var keys []IndexKey | ||
keys = append(keys, IndexKey{ | ||
Name: "mapName", | ||
Type: "varchar(255)", | ||
}) | ||
return keys | ||
} | ||
|
||
func (i *MapVoteStatsIndexer) Counters() []string { | ||
return []string{"ballots", "votes", "wins"} | ||
} | ||
|
||
func OneIfGreater(a int64, b int64, c int64) int { | ||
if a > b && a > c { | ||
return 1 | ||
} | ||
|
||
return 0 | ||
} | ||
|
||
func (i *MapVoteStatsIndexer) Index(votes MapVotes) []Index { | ||
var indices []Index | ||
|
||
indices = append(indices, Index{ | ||
Keys: []interface{}{votes.Map1Name}, | ||
Counters: map[string]int{"ballots": 1, | ||
"votes": int(votes.Map1Votes), | ||
"wins": OneIfGreater(votes.Map1Votes, votes.Map2Votes, votes.RandomVotes)}, | ||
}) | ||
|
||
indices = append(indices, Index{ | ||
Keys: []interface{}{votes.Map2Name}, | ||
Counters: map[string]int{"ballots": 1, | ||
"votes": int(votes.Map2Votes), | ||
"wins": OneIfGreater(votes.Map2Votes, votes.Map1Votes, votes.RandomVotes)}, | ||
}) | ||
|
||
return indices | ||
} | ||
|
||
func main() { | ||
indexer := MapVoteStatsIndexer{} | ||
err := Run(&indexer) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters