new history function

This commit is contained in:
Michael Simard
2020-12-11 07:56:06 -06:00
parent b0834a8044
commit 172b4fed06

View File

@@ -23,10 +23,20 @@ struct StatsController: RouteCollection {
statsRoute.get("test", use: test)
statsRoute.post("logMatch", use: logMatch)
statsRoute.get("history", use: history)
}
func history(req: Request) throws -> EventLoopFuture<[Match]> {
return Match.query(on: req.db).sort(\.$date, .descending).limit(20).all().map { (matches) -> ([Match]) in
return matches
}
}
func logMatch(req: Request) throws -> EventLoopFuture<Match> {