示例#1
0
func main() {
	c := ConnectToMongoAndGetCollection()
	humans, ogres := GetAllRelevantSessions(c)
	allSessionPairs := generateAllSessionPairs(humans, ogres)
	fmt.Println("Generated", len(allSessionPairs), "session pairs!")
	r := lib.ConnectToRedis()
	insertPairsIntoRedisQueue(allSessionPairs, r)
}
示例#2
0
func main() {
	c, m := ConnectToMongoAndGetCollection()
	unprocessedSessions := GetAllRelevantSessions(c)
	r := lib.ConnectToRedis()
	var results []GameSessionResult
	for _, session := range unprocessedSessions {
		results = append(results, getWinsAndLosses(session, r))
	}

	increasingWins := func(r1, r2 *GameSessionResult) bool {
		return (r1.Wins - r1.Losses) > (r2.Wins - r2.Losses)
	}
	OrderedBy(increasingWins).Sort(results)
	for i, result := range results {
		results[i] = result.getCreatorName(c)
	}
	for i, result := range results {
		results[i] = result.getSessionDetails(m)
	}
	var ogres []GameSessionResult
	var humans []GameSessionResult
	for _, result := range results {
		if result.Session.Team == "ogres" {
			ogres = append(ogres, result)
		} else {
			humans = append(humans, result)
		}
	}

	fmt.Println("Top ogres")
	for _, result := range ogres {
		fmt.Printf("%d,%s,%s,%s,%d,%d,%d\n", result.PreliminaryRank, bson.ObjectId(result.Session.ID), result.CreatorName, result.Email, result.Playtime, result.Wins, result.Losses)
	}
	fmt.Println("Top humans")
	for _, result := range humans {
		fmt.Printf("%d,%s,%s,%s,%d,%d,%d\n", result.PreliminaryRank, bson.ObjectId(result.Session.ID), result.CreatorName, result.Email, result.Playtime, result.Wins, result.Losses)
	}

}