diff --git a/Sources/App/Controllers/StatsController.swift b/Sources/App/Controllers/StatsController.swift index c71d6ce..bd2696b 100644 --- a/Sources/App/Controllers/StatsController.swift +++ b/Sources/App/Controllers/StatsController.swift @@ -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 {