From 26fdc1e39aac84062811900cd444963e2b63fe68 Mon Sep 17 00:00:00 2001 From: Michael Simard Date: Mon, 16 Nov 2020 18:47:37 -0600 Subject: [PATCH] optimization --- Sources/App/Controllers/StatsController.swift | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/App/Controllers/StatsController.swift b/Sources/App/Controllers/StatsController.swift index 3158bb6..9e64b7c 100644 --- a/Sources/App/Controllers/StatsController.swift +++ b/Sources/App/Controllers/StatsController.swift @@ -89,10 +89,10 @@ struct StatsController: RouteCollection { let startTime = Date() - print ("c \(Date().timeIntervalSince(startTime))") +//print ("c \(Date().timeIntervalSince(startTime))") let daysPlayed = getDaysPlayed(matches: matches) - print ("c \(Date().timeIntervalSince(startTime))") + // print ("c \(Date().timeIntervalSince(startTime))") var cumulativeRatios : [DataPoint] = [] var cumulativeWins:Int = 0 @@ -171,21 +171,21 @@ struct StatsController: RouteCollection { date = Calendar.current.date(byAdding: .month, value: 1, to: date)! } while (date.month != (Date().month + 1) || date.year != Date().year) - print (date - Date().timeIntervalSince(startTime)) + // print (date - Date().timeIntervalSince(startTime)) return Match.query(on: req.db).all().map { (matches) -> AllStats in let overallStats = self.getStats(matches: matches) - print ( Date().timeIntervalSince(startTime)) + // print ( Date().timeIntervalSince(startTime)) let mwStats = self.getStats(matches: matches.filter({ (match) -> Bool in return match.codGame == "mw" })) - print ( Date().timeIntervalSince(startTime)) + // print ( Date().timeIntervalSince(startTime)) let bocwStats = self.getStats(matches: matches.filter({ (match) -> Bool in return match.codGame == "bocw" })) - print ( Date().timeIntervalSince(startTime)) + // print ( Date().timeIntervalSince(startTime)) let monthlyStats = previousMonths.reversed().map { (codDate) -> MonthStats in @@ -194,12 +194,12 @@ struct StatsController: RouteCollection { } return MonthStats(month: codDate.month, year: codDate.year, stats: self.getStats(matches: relevantMatches )) } - print ( Date().timeIntervalSince(startTime)) + // print ( Date().timeIntervalSince(startTime)) let cumulativeWinLossRatios = self.getCumulativeWinLossRatios(matches: matches) - print ( Date().timeIntervalSince(startTime)) + // print ( Date().timeIntervalSince(startTime)) let highestWinLossRatio = cumulativeWinLossRatios.reduce("0") { (highestRatio, dataPoint) -> String in if dataPoint.y > Double(highestRatio)!{ @@ -207,7 +207,7 @@ struct StatsController: RouteCollection { } return highestRatio } - print ( Date().timeIntervalSince(startTime)) + // print ( Date().timeIntervalSince(startTime)) let mostRecentDailyStats = self.mostRecentDailyStats(matches: matches) @@ -612,7 +612,7 @@ struct StatsController: RouteCollection { if !(stats.totalWins == 0 && stats.totalLosses == 0) { let date = self.createDate(day: first.day, month: first.month, year: first.year, hour: first.hour + 6, minute:first.minute) // 6 hours to make sure we pick a time that isnt on borders of us time zones - print ("p \(date.timeIntervalSince1970)") + // print ("p \(date.timeIntervalSince1970)") let x = Double(cumulativeWinLossRatios.count) let d = Date(timeIntervalSince1970: date.timeIntervalSince1970)