fixed history

This commit is contained in:
Michael Simard
2020-12-16 11:36:54 -06:00
parent a7969813ae
commit 3d0a14ba4a

View File

@@ -26,9 +26,6 @@ struct StatsController: RouteCollection {
statsRoute.get("history","page",":page", use: history) statsRoute.get("history","page",":page", use: history)
statsRoute.get("history", use: history) statsRoute.get("history", use: history)
} }
@@ -38,14 +35,12 @@ struct StatsController: RouteCollection {
return Match.query(on: req.db).count().flatMap { (totalMatches) -> EventLoopFuture<MatchHistory> in return Match.query(on: req.db).count().flatMap { (totalMatches) -> EventLoopFuture<MatchHistory> in
let startRecord = min (page * 20 + 20, totalMatches) let startRecord = min (page * 20, totalMatches)
let lastRecord = min (startRecord + 20, totalMatches) let lastRecord = min (startRecord + 20, totalMatches)
return Match.query(on: req.db).sort(\.$date, .descending).range(startRecord..<lastRecord).all().map { (matches) -> (MatchHistory) in return Match.query(on: req.db).sort(\.$date, .descending).range(startRecord..<lastRecord).all().map { (matches) -> (MatchHistory) in
return MatchHistory(total:totalMatches, matches: matches, hasMorePages: lastRecord < totalMatches) return MatchHistory(total:totalMatches, matches: matches, hasMorePages: lastRecord < totalMatches)
} }
} }