// // Stats.swift // App // // Created by Michael Simard on 5/29/20. // import Foundation import Fluent import Vapor struct DataPoint : Content { var x:Double var y:Double var label:String init(x:Double, y:Double, label:String) { self.x = x self.y = y self.label = label } } final class AllStats: Content { var overall:StatsWithMostRecentDailyRecord var mwStats:StatsWithMostRecentDailyRecord var bocwStats:StatsWithMostRecentDailyRecord var byMonth: [MonthStats] var mostRecentRecord:String init( overall:StatsWithMostRecentDailyRecord, mwStats:StatsWithMostRecentDailyRecord, bocwStats:StatsWithMostRecentDailyRecord, byMonth:[MonthStats], mostRecentRecord:String) { self.overall = overall self.byMonth = byMonth self.mostRecentRecord = mostRecentRecord self.mwStats = mwStats; self.bocwStats = bocwStats; } } final class OverallStats: Content { var overall:StatsWithMostRecentDailyRecord var mwStats:StatsWithMostRecentDailyRecord var bocwStats:StatsWithMostRecentDailyRecord var mostRecentRecord:String init( overall:StatsWithMostRecentDailyRecord, mwStats:StatsWithMostRecentDailyRecord, bocwStats:StatsWithMostRecentDailyRecord, mostRecentRecord:String){ self.overall = overall self.mwStats = mwStats; self.bocwStats = bocwStats; self.mostRecentRecord = mostRecentRecord } } final class MonthStats: Content { var stats:Stats var month:String var year: String init( month:Int, year:Int, stats:Stats) { self.month = Utilities.monthToString(month: month) self.year = String(year) self.stats = stats } } final class Stats: Content { var winLossRatio:String var totalWins:Int var totalLosses:Int init( winLoss:String, totalWins:Int, totalLosses:Int) { self.winLossRatio = winLoss self.totalWins = totalWins self.totalLosses = totalLosses } } final class StatsWithMostRecentDailyRecord: Content { var winLossRatio:String var totalWins:Int var totalLosses:Int var mostRecentRecord:String init( winLoss:String, totalWins:Int, totalLosses:Int, mostRecentRecord:String ) { self.winLossRatio = winLoss self.totalWins = totalWins self.totalLosses = totalLosses self.mostRecentRecord = mostRecentRecord } } final class AllDailyStats: Content { var dailyStats : [DailyStats] init(dailyStats:[DailyStats]) { self.dailyStats = dailyStats } } final class AllRollingStats: Content { var cumulativeStats:[DailyStats] } final class DailyStats: Content { var day: String var month:String var year: String var cumulativeRatio:String var stats:Stats init(day:Int, month:Int, year:Int, stats:Stats, cumulativeRatio:String) { self.day = String(day) self.month = Utilities.monthToString(month: month) self.year = String(year) self.stats = stats self.cumulativeRatio = cumulativeRatio } } class Utilities { class func monthToString(month:Int) -> String { switch month { case 1 : return "January" case 2: return "February" case 3: return "March" case 4: return "April" case 5: return "May" case 6: return "June" case 7: return "July" case 8: return "August" case 9: return "September" case 10: return "October" case 11: return "November" case 12: return "December" default: return "error" } } }