stats tweaks, added apocalypse
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user