fixed history
This commit is contained in:
@@ -26,9 +26,6 @@ struct StatsController: RouteCollection {
|
||||
|
||||
statsRoute.get("history","page",":page", 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
|
||||
|
||||
let startRecord = min (page * 20 + 20, totalMatches)
|
||||
let startRecord = min (page * 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 MatchHistory(total:totalMatches, matches: matches, hasMorePages: lastRecord < totalMatches)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user