win rate, 2020 bug

This commit is contained in:
Michael Simard
2021-01-22 11:58:18 -06:00
parent 3ae103acbb
commit 69829a9f01
2 changed files with 19 additions and 1 deletions

View File

@@ -154,7 +154,20 @@ struct StatsController: RouteCollection {
let startDate = userCalendar.date(from: dateComponents)
return Match.query(on: req.db).filter(\.$date > startDate!).all().map { (matches) -> (Stats) in
var endDateComponenents = DateComponents()
endDateComponenents.year = year + 1
endDateComponenents.month = 1
endDateComponenents.day = 1
endDateComponenents.timeZone = TimeZone(abbreviation: "EST") // Japan Standard Time
endDateComponenents.hour = 8
endDateComponenents.minute = 0
let endDate = userCalendar.date(from: endDateComponenents)
return Match.query(on: req.db).filter(\.$date > startDate!).filter(\.$date < endDate!).all().map { (matches) -> (Stats) in
return self.getStats(matches: matches)
}
}
@@ -563,6 +576,7 @@ struct StatsController: RouteCollection {
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),
DashboardItem(title: "Win Rate", content: "\(overallStats!.winRate)", title2: "", content2: ""),
DashboardItem(title: "Cold War Overall", content: bocwStats!.record, title2: "Ratio", content2: bocwStats!.winLossRatio),
DashboardItem(title: "With Hyder", content: hyderStats[0].record, title2: "Ratio", content2: hyderStats[0].winLossRatio),
DashboardItem(title: "No Hyder", content: hyderStats[1].record, title2: "Ratio", content2: hyderStats[1].winLossRatio),