compatable with older swifts

This commit is contained in:
Michael Simard
2020-11-16 08:57:38 -06:00
parent 8d94b42439
commit 1f7afdff68

View File

@@ -94,7 +94,7 @@ struct StatsController: RouteCollection {
var cumulativeLosses:Int = 0 var cumulativeLosses:Int = 0
for (i, day) in daysPlayed.enumerated() { 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 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 return Match.query(on: req.db).all().map { (matches) -> AllStats in
let overallStats = getStats(matches: matches) let overallStats = self.getStats(matches: matches)
let mwStats = getStats(matches: matches.filter({ (match) -> Bool in let mwStats = self.getStats(matches: matches.filter({ (match) -> Bool in
return match.codGame == "mw" 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" return match.codGame == "bocw"
})) }))
@@ -132,10 +132,10 @@ struct StatsController: RouteCollection {
let relevantMatches = matches.filter { (match) -> Bool in let relevantMatches = matches.filter { (match) -> Bool in
return match.date.month == codDate.month 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 let highestWinLossRatio = cumulativeWinLossRatios.reduce("0") { (highestRatio, dataPoint) -> String in
if dataPoint.y > Double(highestRatio)!{ if dataPoint.y > Double(highestRatio)!{