speed update, new table for cached stats
This commit is contained in:
@@ -17,7 +17,6 @@ struct MatchController: RouteCollection {
|
||||
matchRoute.delete("delete", "id",":id", use: deleteMatch)
|
||||
matchRoute.post("update", "id",":id", use: updateMatch)
|
||||
matchRoute.post("add", use: logMatch)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,20 +27,21 @@ struct MatchController: RouteCollection {
|
||||
|
||||
let newMatch = try req.content.decode(Match.self)
|
||||
|
||||
|
||||
return Match.find(id, on: req.db)
|
||||
.unwrap(or: Abort(.notFound))
|
||||
.flatMap {
|
||||
|
||||
|
||||
$0.update(newMatch: newMatch)
|
||||
|
||||
return $0.save(on: req.db)
|
||||
|
||||
}
|
||||
.map { .ok }
|
||||
|
||||
|
||||
|
||||
.map {
|
||||
|
||||
req.application.threadPool.runIfActive(eventLoop: req.eventLoop.next()) {
|
||||
DBHelpers.relcalulateRecords(db: req.db) { MessagePort in}
|
||||
}
|
||||
return .ok
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func deleteMatch(req: Request) throws -> EventLoopFuture<HTTPStatus> {
|
||||
@@ -51,14 +51,36 @@ struct MatchController: RouteCollection {
|
||||
return Match.find(id, on: req.db)
|
||||
.unwrap(or: Abort(.notFound))
|
||||
.flatMap { $0.delete(on: req.db) }
|
||||
.map { .ok }
|
||||
.map {
|
||||
|
||||
|
||||
req.application.threadPool.runIfActive(eventLoop: req.eventLoop.next()) {
|
||||
DBHelpers.relcalulateRecords(db: req.db) { MessagePort in}
|
||||
}
|
||||
|
||||
return .ok
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func logMatch(req: Request) throws -> EventLoopFuture<Match> {
|
||||
|
||||
let newMatch = try req.content.decode(Match.self)
|
||||
return newMatch.save(on: req.db).map { newMatch}
|
||||
return newMatch.save(on: req.db).map {
|
||||
|
||||
|
||||
|
||||
|
||||
req.application.threadPool.runIfActive(eventLoop: req.eventLoop.next()) {
|
||||
DBHelpers.relcalulateRecords(db: req.db) { MessagePort in}
|
||||
}
|
||||
|
||||
|
||||
return newMatch
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user