//// //// StatsAPIController.swift //// App //// //// Created by Michael Simard on 5/29/20. //// // //import Fluent //import Vapor // // // // // //protocol ContentController { // associatedtype Model: Fluent.Model //} // //protocol StatsContentRepresentable { // associatedtype StatsItem: Content // var statsContent : StatsItem { get } //} // // //protocol StatsContentController: ContentController where Model: StatsContentRepresentable { // // func stats (_:Request) throws -> EventLoopFuture> // func setupStatsRoute( routes: RoutesBuilder) //} // //extension StatsContentController { // // // func stats (req:Request) throws -> EventLoopFuture> { // return Model.query(on: req.db).paginate(for: req).map { $0.map(\.statsContent)} // // } // // func setupStatsRoute( routes: RoutesBuilder) // { // routes.get(use: self.stats) // } // //} // // // ////*********** // //final class StatsModel: Model, Content { // typealias IDValue = <#type#> // // static var schema: String // // init() { // <#code#> // } // // var winLoss:String // var totalWins:Int // var totalLosses:Int // init( winLoss:String, totalWins:Int, totalLosses:Int) { // // self.winLoss = winLoss // self.totalWins = totalWins // self.totalLosses = totalLosses // } //} // //extension StatsModel: StatsContentRepresentable { // // struct StatsItem: Content { // // var winLoss:String // var totalWins:Int // var totalLosses:Int // // init(model:StatsModel) { // // self.winLoss = model.winLoss // self.totalWins = model.totalWins // self.totalLosses = model.totalLosses // } // } // // var statsContent: StatsItem { .init(model:self) } //} // // ////*********** // // //struct StatsAPIController: StatsContentController { // // typealias Model = StatsModel // // //} // //struct StatsRouter: RouteCollection { // // func boot(routes: RoutesBuilder) throws { // let statsRoute = routes.grouped("api", "stats") // // StatsAPIController().setupStatsRoute(routes: statsRoute) // //// statsRoute.get("allMatches", use: index) //// statsRoute.get("totalWins", use: totalWins) //// statsRoute.get("totalLosses", use: totalLosses) // //statsRoute.get("overall", use: totalLosses) // // //beaconsRoute.get("overallStats", use: index) // //beaconsRoute.post("", use: create) // // beaconsRoute.delete(":beaconID", use: delete) // // } //}