From 15f9e0cf86bab9e66b365b4d8360608bccb070e7 Mon Sep 17 00:00:00 2001 From: Michael Simard Date: Fri, 26 Feb 2021 18:19:58 -0600 Subject: [PATCH] stats tweaks, added apocalypse --- Sources/App/Controllers/StatsController.swift | 41 +++++++++++++++---- Sources/App/Data/MapData.swift | 3 +- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Sources/App/Controllers/StatsController.swift b/Sources/App/Controllers/StatsController.swift index 0c36e94..dc6b8e4 100644 --- a/Sources/App/Controllers/StatsController.swift +++ b/Sources/App/Controllers/StatsController.swift @@ -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{ @@ -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), diff --git a/Sources/App/Data/MapData.swift b/Sources/App/Data/MapData.swift index 87cadac..c442ce6 100644 --- a/Sources/App/Data/MapData.swift +++ b/Sources/App/Data/MapData.swift @@ -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") ]