player count stats
This commit is contained in:
@@ -11,6 +11,7 @@ struct CODDate {
|
||||
let minute:Int
|
||||
}
|
||||
|
||||
|
||||
struct StatsController: RouteCollection {
|
||||
func boot(routes: RoutesBuilder) throws {
|
||||
let statsRoute = routes.grouped("cod-tracker","api", "stats")
|
||||
@@ -425,6 +426,10 @@ struct StatsController: RouteCollection {
|
||||
var mwStats:StatsWithMostRecentDailyRecord?
|
||||
var bocwStats:StatsWithMostRecentDailyRecord?
|
||||
var mostRecentStats:Stats?
|
||||
var mwSixPlayers:Stats?
|
||||
var mwFivePlayers:Stats?
|
||||
var mwFourPlayers:Stats?
|
||||
|
||||
var mapStats:[Int:Stats]?
|
||||
var worstMap:Int?
|
||||
var bestMap:Int?
|
||||
@@ -441,9 +446,6 @@ struct StatsController: RouteCollection {
|
||||
mwStats = self.getStatsWithMostRecentDailyRecord(sortedMatches: matches.filter({ (match) -> Bool in
|
||||
return match.codGame == "mw" && self.shouldCountMatch(match: match )
|
||||
}))
|
||||
|
||||
//print ("mw stats done \(Date().timeIntervalSince(startTime))")
|
||||
|
||||
group.leave()
|
||||
|
||||
}
|
||||
@@ -489,19 +491,46 @@ struct StatsController: RouteCollection {
|
||||
group.leave()
|
||||
|
||||
}
|
||||
|
||||
group.enter()
|
||||
queue.async {
|
||||
mwFourPlayers = getStatsByPlayerCount(matches: matches, playerCount: 4)
|
||||
group.leave()
|
||||
}
|
||||
|
||||
|
||||
group.enter()
|
||||
queue.async {
|
||||
mwFivePlayers = getStatsByPlayerCount(matches: matches, playerCount: 5)
|
||||
group.leave()
|
||||
}
|
||||
|
||||
|
||||
|
||||
group.enter()
|
||||
queue.async {
|
||||
mwSixPlayers = getStatsByPlayerCount(matches: matches, playerCount: 6)
|
||||
group.leave()
|
||||
}
|
||||
|
||||
|
||||
group.wait()
|
||||
|
||||
let dashboardItems = [
|
||||
DashboardItem(title: "Overall", content: overallStats!.record, title2: "Ratio", content2: overallStats!.winLossRatio),
|
||||
|
||||
DashboardItem(title: "Total MW Games", content: "\(mwStats!.totalWins + mwStats!.totalLosses)" , title2:"", content2:""),
|
||||
DashboardItem(title: "MW Overall", content: mwStats!.record, title2: "Ratio", content2: mwStats!.winLossRatio),
|
||||
DashboardItem(title: "MW 6 Players ", content: mwSixPlayers!.record, title2: "Ratio", content2: mwSixPlayers!.winLossRatio),
|
||||
DashboardItem(title: "MW 5 Players ", content: mwFivePlayers!.record, title2: "Ratio", content2: mwFivePlayers!.winLossRatio),
|
||||
DashboardItem(title: "MW 4 Players ", content: mwFourPlayers!.record, title2: "Ratio", content2: mwFourPlayers!.winLossRatio),
|
||||
DashboardItem(title: "Overall", content: overallStats!.record, title2: "Ratio", content2: overallStats!.winLossRatio),
|
||||
DashboardItem(title: "Cold War Overall", content: bocwStats!.record, title2: "Ratio", content2: bocwStats!.winLossRatio),
|
||||
DashboardItem(title: "With Hyder", content: hyderStats[0].record, title2: "Ratio", content2: hyderStats[0].winLossRatio),
|
||||
DashboardItem(title: "No Hyder", content: hyderStats[1].record, title2: "Ratio", content2: hyderStats[1].winLossRatio),
|
||||
DashboardItem(title: "Best Map", content: MapData.allMaps[bestMap!]?.name ?? "error", title2: "Ratio", content2: "\(mapStats![bestMap!]!.winLossRatio) \(mapStats![bestMap!]!.record)"),
|
||||
DashboardItem(title: "Worst Map", content: MapData.allMaps[worstMap!]?.name ?? "error", title2: "Ratio", content2: "\(mapStats![worstMap!]!.winLossRatio) \(mapStats![worstMap!]!.record)"),
|
||||
DashboardItem(title: "Final Kills Ruined by Adam", content: "\(matches.filter{$0.finalKillRuinedPlayerId == 6}.count + 7)", title2: "", content2: ""),
|
||||
|
||||
]
|
||||
return OverallStats(overall: overallStats!, mwStats: mwStats!, bocwStats: bocwStats!, mostRecentRecord: "Temporarily Unavailable", statsWithHyder:hyderStats[0], statsWithoutHyder: hyderStats[1], dashboardItems:dashboardItems)
|
||||
}
|
||||
@@ -545,6 +574,13 @@ struct StatsController: RouteCollection {
|
||||
}.reversed()
|
||||
}
|
||||
|
||||
func getStatsByPlayerCount(matches:[Match], playerCount:Int) -> Stats {
|
||||
|
||||
return getStats(matches: matches.filter{$0.playerList.count == playerCount})
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
func getBestMap (records :[ Int:Stats] ) -> Int {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user