added post method for updating match

This commit is contained in:
Michael Simard
2020-12-21 10:26:32 -06:00
parent 3d0a14ba4a
commit 87726f6b99
2 changed files with 25 additions and 29 deletions

View File

@@ -26,6 +26,8 @@ struct StatsController: RouteCollection {
statsRoute.get("history","page",":page", use: history)
statsRoute.get("history", use: history)
}
@@ -47,43 +49,15 @@ struct StatsController: RouteCollection {
}
else {
return Match.query(on: req.db).count().flatMap { (totalMatches) -> EventLoopFuture<MatchHistory> in
return Match.query(on: req.db).sort(\.$date, .descending).limit(20).all().map { (matches) -> (MatchHistory) in
return MatchHistory(total:totalMatches, matches: matches, hasMorePages: totalMatches > 20)
}
}
}
// let startRecord = page * 20
//
//
//
//
// if totalRecords.map
//
//
// return Match.query(on: req.db).sort(\.$date, .descending).range(startRecord...).all().map { (matches) -> ([Match]) in
// return matches
// }
// }
// else {
// return Match.query(on: req.db).sort(\.$date, .descending).limit(20).all().map { (matches) -> ([Match]) in
// return matches
// }
// }
}