diff --git a/Sources/App/Controllers/StatsController.swift b/Sources/App/Controllers/StatsController.swift index a0c4442..9fcf7d0 100644 --- a/Sources/App/Controllers/StatsController.swift +++ b/Sources/App/Controllers/StatsController.swift @@ -94,7 +94,7 @@ struct StatsController: RouteCollection { var cumulativeLosses:Int = 0 for (i, day) in daysPlayed.enumerated() { - let stats = getStats(matches: matches.filter({ (match) -> Bool in + let stats = self.getStats(matches: matches.filter({ (match) -> Bool in return match.date.day == day.day && match.date.year == day.year && match.date.month == day.month })) @@ -120,11 +120,11 @@ struct StatsController: RouteCollection { return Match.query(on: req.db).all().map { (matches) -> AllStats in - let overallStats = getStats(matches: matches) - let mwStats = getStats(matches: matches.filter({ (match) -> Bool in + let overallStats = self.getStats(matches: matches) + let mwStats = self.getStats(matches: matches.filter({ (match) -> Bool in return match.codGame == "mw" })) - let bocwStats = getStats(matches: matches.filter({ (match) -> Bool in + let bocwStats = self.getStats(matches: matches.filter({ (match) -> Bool in return match.codGame == "bocw" })) @@ -132,10 +132,10 @@ struct StatsController: RouteCollection { let relevantMatches = matches.filter { (match) -> Bool in return match.date.month == codDate.month } - return MonthStats(month: codDate.month, year: codDate.year, stats: getStats(matches: relevantMatches )) + return MonthStats(month: codDate.month, year: codDate.year, stats: self.getStats(matches: relevantMatches )) } - let cumulativeWinLossRatios = getCumulativeWinLossRatios(matches: matches) + let cumulativeWinLossRatios = self.getCumulativeWinLossRatios(matches: matches) let highestWinLossRatio = cumulativeWinLossRatios.reduce("0") { (highestRatio, dataPoint) -> String in if dataPoint.y > Double(highestRatio)!{