optimization
This commit is contained in:
@@ -89,10 +89,10 @@ struct StatsController: RouteCollection {
|
|||||||
|
|
||||||
let startTime = Date()
|
let startTime = Date()
|
||||||
|
|
||||||
print ("c \(Date().timeIntervalSince(startTime))")
|
//print ("c \(Date().timeIntervalSince(startTime))")
|
||||||
|
|
||||||
let daysPlayed = getDaysPlayed(matches: matches)
|
let daysPlayed = getDaysPlayed(matches: matches)
|
||||||
print ("c \(Date().timeIntervalSince(startTime))")
|
// print ("c \(Date().timeIntervalSince(startTime))")
|
||||||
|
|
||||||
var cumulativeRatios : [DataPoint] = []
|
var cumulativeRatios : [DataPoint] = []
|
||||||
var cumulativeWins:Int = 0
|
var cumulativeWins:Int = 0
|
||||||
@@ -171,21 +171,21 @@ struct StatsController: RouteCollection {
|
|||||||
date = Calendar.current.date(byAdding: .month, value: 1, to: date)!
|
date = Calendar.current.date(byAdding: .month, value: 1, to: date)!
|
||||||
} while (date.month != (Date().month + 1) || date.year != Date().year)
|
} 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
|
return Match.query(on: req.db).all().map { (matches) -> AllStats in
|
||||||
let overallStats = self.getStats(matches: matches)
|
let overallStats = self.getStats(matches: matches)
|
||||||
print ( Date().timeIntervalSince(startTime))
|
// print ( Date().timeIntervalSince(startTime))
|
||||||
|
|
||||||
let mwStats = self.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"
|
||||||
}))
|
}))
|
||||||
print ( Date().timeIntervalSince(startTime))
|
// print ( Date().timeIntervalSince(startTime))
|
||||||
|
|
||||||
let bocwStats = self.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"
|
||||||
}))
|
}))
|
||||||
print ( Date().timeIntervalSince(startTime))
|
// print ( Date().timeIntervalSince(startTime))
|
||||||
|
|
||||||
|
|
||||||
let monthlyStats = previousMonths.reversed().map { (codDate) -> MonthStats in
|
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 ))
|
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)
|
let cumulativeWinLossRatios = self.getCumulativeWinLossRatios(matches: matches)
|
||||||
|
|
||||||
print ( Date().timeIntervalSince(startTime))
|
// print ( Date().timeIntervalSince(startTime))
|
||||||
|
|
||||||
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)!{
|
||||||
@@ -207,7 +207,7 @@ struct StatsController: RouteCollection {
|
|||||||
}
|
}
|
||||||
return highestRatio
|
return highestRatio
|
||||||
}
|
}
|
||||||
print ( Date().timeIntervalSince(startTime))
|
// print ( Date().timeIntervalSince(startTime))
|
||||||
|
|
||||||
|
|
||||||
let mostRecentDailyStats = self.mostRecentDailyStats(matches: matches)
|
let mostRecentDailyStats = self.mostRecentDailyStats(matches: matches)
|
||||||
@@ -612,7 +612,7 @@ struct StatsController: RouteCollection {
|
|||||||
if !(stats.totalWins == 0 && stats.totalLosses == 0) {
|
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
|
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 x = Double(cumulativeWinLossRatios.count)
|
||||||
|
|
||||||
let d = Date(timeIntervalSince1970: date.timeIntervalSince1970)
|
let d = Date(timeIntervalSince1970: date.timeIntervalSince1970)
|
||||||
|
|||||||
Reference in New Issue
Block a user