update date decoder

This commit is contained in:
Michael Simard
2020-12-10 08:10:44 -06:00
parent c7cb5fc54a
commit b0834a8044
2 changed files with 18 additions and 10 deletions

View File

@@ -24,20 +24,13 @@ struct StatsController: RouteCollection {
statsRoute.post("logMatch", use: logMatch)
}
struct CreateMatchRequestBody: Content {
let match: Match
func makeMatch(match:Match) -> Match {
return Match(id: match.id, map: match.map, win: match.win, date: match.date, roundsWon: match.roundsWon, roundsLost: match.roundsLost, codGame: match.codGame, notes: match.notes, players: match.players)
}
}
func logMatch(req: Request) throws -> EventLoopFuture<Match> {
let newMatch = try req.content.decode(Match.self)
let newMatch = try req.content.decode(Match.self)
return newMatch.save(on: req.db).map { newMatch}
}
@@ -246,6 +239,7 @@ struct StatsController: RouteCollection {
let mostRecentDailyStats = self.mostRecentDailyStats(matches: matches)
return AllStats.init(overall: overallStats,mwStats: mwStats, bocwStats: bocwStats, byMonth: monthlyStats, highestWinLossRatio: highestWinLossRatio, dataPoints: cumulativeWinLossRatios, mostRecentRecord: "\(mostRecentDailyStats.totalWins) - \(mostRecentDailyStats.totalLosses)")
}