win rate, 2020 bug
This commit is contained in:
@@ -154,7 +154,20 @@ struct StatsController: RouteCollection {
|
|||||||
let startDate = userCalendar.date(from: dateComponents)
|
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)
|
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: "Overall", content: overallStats!.record, title2: "Ratio", content2: overallStats!.winLossRatio),
|
||||||
DashboardItem(title: "2021 Overall", content: statsFor2021.record, title2: "Ratio", content2: statsFor2021.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: "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: "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: "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),
|
DashboardItem(title: "No Hyder", content: hyderStats[1].record, title2: "Ratio", content2: hyderStats[1].winLossRatio),
|
||||||
|
|||||||
@@ -127,6 +127,10 @@ final class StatsWithMostRecentDailyRecord: Content {
|
|||||||
var totalLosses:Int
|
var totalLosses:Int
|
||||||
var mostRecentRecord:String
|
var mostRecentRecord:String
|
||||||
|
|
||||||
|
|
||||||
|
var winRate:String {
|
||||||
|
return "\((Double((Double(totalWins)/Double(totalWins + totalLosses))) * 100.0).truncate(places: 1))%"
|
||||||
|
}
|
||||||
init( winLoss:String, totalWins:Int, totalLosses:Int, mostRecentRecord:String ) {
|
init( winLoss:String, totalWins:Int, totalLosses:Int, mostRecentRecord:String ) {
|
||||||
self.winLossRatio = winLoss
|
self.winLossRatio = winLoss
|
||||||
self.totalWins = totalWins
|
self.totalWins = totalWins
|
||||||
|
|||||||
Reference in New Issue
Block a user