stats tweaks, added apocalypse

This commit is contained in:
Michael Simard
2021-02-26 18:19:58 -06:00
parent 74b034e104
commit 15f9e0cf86
2 changed files with 36 additions and 8 deletions

View File

@@ -131,11 +131,38 @@ struct StatsController: RouteCollection {
private func shouldCountMatch (match:Match) -> Bool {
let isColdWar = match.codGame == "bocw"
let numberOfPlayers = self.numberOfPlayers(match: match)
if isColdWar {
if numberOfPlayers == 0 {
return true
}
else if numberOfPlayers > 4 {
return true
}
else {
return false
}
}
else {
if numberOfPlayers > 4 {
return true
}
else if numberOfPlayers == 4 {
return match.date > Date(timeIntervalSince1970: 1612159200)
} // February 1 2021
else {
return false
}
}
return !isColdWar || (isColdWar && (numberOfPlayers == 0 || numberOfPlayers > 4 ))
}
}
func getStatsForYear(year:Int, req: Request) -> EventLoopFuture<Stats>{
@@ -475,7 +502,7 @@ struct StatsController: RouteCollection {
var mostRecentStats:Stats?
var mwSixPlayers:Stats?
var mwFivePlayers:Stats?
var mwFourPlayers:Stats?
var overallFourPlayers:Stats?
var mapStats:[Int:Stats]?
var worstMap:Int?
@@ -543,21 +570,21 @@ struct StatsController: RouteCollection {
group.enter()
queue.async {
mwFourPlayers = self.getStatsByPlayerCount(matches: matches, playerCount: 4)
overallFourPlayers = self.getStatsByPlayerCount(matches: matches.filter{$0.date > Date(timeIntervalSince1970: 1612159200)}, playerCount: 4)
group.leave()
}
group.enter()
queue.async {
mwFivePlayers = self.getStatsByPlayerCount(matches: matches, playerCount: 5)
mwFivePlayers = self.getStatsByPlayerCount(matches: matches.filter{$0.codGame == "mw"}, playerCount: 5)
group.leave()
}
group.enter()
queue.async {
mwSixPlayers = self.getStatsByPlayerCount(matches: matches, playerCount: 6)
mwSixPlayers = self.getStatsByPlayerCount(matches: matches.filter{$0.codGame == "mw"}, playerCount: 6)
group.leave()
}
@@ -570,7 +597,7 @@ struct StatsController: RouteCollection {
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 4 Players ", content: overallFourPlayers!.record, title2: "Ratio", content2: overallFourPlayers!.winLossRatio),
DashboardItem(title: "Overall", content: overallStats!.record, title2: "Ratio", content2: overallStats!.winLossRatio),
DashboardItem(title: "2021 Overall", content: statsFor2021.record, title2: "Ratio", content2: statsFor2021.winLossRatio),
DashboardItem(title: "2020 Overall", content: statsFor2020.record, title2: "Ratio", content2: statsFor2020.winLossRatio),

View File

@@ -45,7 +45,8 @@ class MapData {
30: Map(id: 30, name: "Raid", imageName: "bocw_raid"),
32: Map(id: 32, name: "Piccadilly", imageName: "mw_piccadilly"),
33: Map(id: 33, name: "Grazna Raid", imageName: "mw_grazna"),
34: Map(id: 34, name: "Express", imageName: "bocw_express")
34: Map(id: 34, name: "Express", imageName: "bocw_express"),
35: Map(id: 35, name: "Apocalypse", imageName: "bocw_apocalypse")
]