new stats
This commit is contained in:
@@ -37,12 +37,19 @@ struct StatsController: RouteCollection {
|
|||||||
let adamAffectedMatches = Match.query(on: db).filter(\.$finalKillRuinedPlayerId == 6).count()
|
let adamAffectedMatches = Match.query(on: db).filter(\.$finalKillRuinedPlayerId == 6).count()
|
||||||
let totalMWGames = Match.query(on: db).filter(\.$codGame == "mw").count()
|
let totalMWGames = Match.query(on: db).filter(\.$codGame == "mw").count()
|
||||||
|
|
||||||
return (statistics.and(adamAffectedMatches).and(totalMWGames)).map { arg -> (DashboardStats) in
|
|
||||||
|
|
||||||
let (((statistics, adamAffectedMatches), totalMWGames)) = arg
|
let colourSchemeConfigs = ColourScheme.query(on: db).all().map { colourScheme in
|
||||||
|
return colourScheme.map { cs in
|
||||||
|
return cs.colorSchemeConfig
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (statistics.and(adamAffectedMatches).and(totalMWGames).and(colourSchemeConfigs)).map { arg -> (DashboardStats) in
|
||||||
|
|
||||||
|
let ((((statistics, adamAffectedMatches), totalMWGames),colors)) = arg
|
||||||
|
|
||||||
|
|
||||||
// return statistics.map { statistics in
|
// return statistics.map { statistics in
|
||||||
return DashboardStats(dashboardItems: (statistics.map({ statisticItem in
|
return DashboardStats(dashboardItems: (statistics.map({ statisticItem in
|
||||||
|
|
||||||
|
|
||||||
@@ -51,12 +58,14 @@ struct StatsController: RouteCollection {
|
|||||||
var content1 = ""
|
var content1 = ""
|
||||||
var content2 = ""
|
var content2 = ""
|
||||||
var sortOrder = 0
|
var sortOrder = 0
|
||||||
|
var backgroundColor = "484848"
|
||||||
|
|
||||||
if statisticItem.codTrackerId == "no_hyder_overall"{
|
if statisticItem.codTrackerId == "no_hyder_overall"{
|
||||||
title2 = "Ratio"
|
title2 = "Ratio"
|
||||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
sortOrder = 100
|
sortOrder = 100
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if statisticItem.codTrackerId == "mw_overall"{
|
else if statisticItem.codTrackerId == "mw_overall"{
|
||||||
@@ -64,6 +73,8 @@ struct StatsController: RouteCollection {
|
|||||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
sortOrder = 20
|
sortOrder = 20
|
||||||
|
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if statisticItem.codTrackerId == "mw_six_players"{
|
else if statisticItem.codTrackerId == "mw_six_players"{
|
||||||
@@ -71,6 +82,7 @@ struct StatsController: RouteCollection {
|
|||||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
sortOrder = 60
|
sortOrder = 60
|
||||||
|
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -86,6 +98,7 @@ struct StatsController: RouteCollection {
|
|||||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
sortOrder = 30
|
sortOrder = 30
|
||||||
|
backgroundColor = colors.first(where: {$0.gameId == "bocw"})?.tileColour ?? backgroundColor
|
||||||
|
|
||||||
}
|
}
|
||||||
else if statisticItem.codTrackerId == "with_hyder_overall"{
|
else if statisticItem.codTrackerId == "with_hyder_overall"{
|
||||||
@@ -99,6 +112,7 @@ struct StatsController: RouteCollection {
|
|||||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
sortOrder = 70
|
sortOrder = 70
|
||||||
|
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
||||||
|
|
||||||
}
|
}
|
||||||
else if statisticItem.codTrackerId == "casual_overall"{
|
else if statisticItem.codTrackerId == "casual_overall"{
|
||||||
@@ -134,23 +148,42 @@ struct StatsController: RouteCollection {
|
|||||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
sortOrder = 41
|
sortOrder = 41
|
||||||
|
backgroundColor = "CC5500"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if statisticItem.codTrackerId == "vg_casual"{
|
||||||
|
title2 = "Ratio"
|
||||||
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
|
sortOrder = -80
|
||||||
|
backgroundColor = colors.first(where: {$0.gameId == "vg"})?.tileColour ?? backgroundColor
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if statisticItem.codTrackerId == "bocw_casual"{
|
||||||
|
title2 = "Ratio"
|
||||||
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
|
sortOrder = -79
|
||||||
|
backgroundColor = colors.first(where: {$0.gameId == "bocw"})?.tileColour ?? backgroundColor
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return DashboardItem(codTrackerId:statisticItem.codTrackerId, title: title, content: content1, title2: title2, content2: content2, sortOrder: sortOrder, backgroundColor:backgroundColor)
|
||||||
|
|
||||||
DashboardItem(codTrackerId:statisticItem.codTrackerId, title: title, content: content1, title2: title2, content2: content2, sortOrder: sortOrder, backgroundColor: statisticItem.codTrackerId == "bocw_nuketown_halloween" ? "FFA500" : "004999")
|
|
||||||
} ) +
|
} ) +
|
||||||
[
|
[
|
||||||
DashboardItem(codTrackerId: "adam_ruined_final_kills", title: "Final Kills Ruined by Adam", content: "\(adamAffectedMatches + 7)", title2: "", content2: "",sortOrder: 1000),
|
DashboardItem(codTrackerId: "adam_ruined_final_kills", title: "Final Kills Ruined by Adam", content: "\(adamAffectedMatches + 7)", title2: "", content2: "",sortOrder: 1000, backgroundColor: "484848"),
|
||||||
DashboardItem(codTrackerId:"total_mw_games", title: "Total MW Games", content: "\(totalMWGames)", title2: "", content2: "", sortOrder: -10),
|
DashboardItem(codTrackerId:"total_mw_games", title: "Total MW Games", content: "\(totalMWGames)", title2: "", content2: "", sortOrder: -10, backgroundColor: colors.first(where: {$0.gameId == "mw"})?.tileColour ?? "484848"
|
||||||
]
|
|
||||||
).sorted{$0.sortOrder < $1.sortOrder}
|
|
||||||
|
),
|
||||||
|
]
|
||||||
|
).sorted{$0.sortOrder < $1.sortOrder}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,10 +293,10 @@ struct StatsController: RouteCollection {
|
|||||||
|
|
||||||
return getCountedMatches(matches: matches.filter({ (match) -> Bool in
|
return getCountedMatches(matches: matches.filter({ (match) -> Bool in
|
||||||
var shouldInclude =
|
var shouldInclude =
|
||||||
match.date.day == lastDayPlayed?.day &&
|
match.date.day == lastDayPlayed?.day &&
|
||||||
match.date.month == lastDayPlayed?.month &&
|
match.date.month == lastDayPlayed?.month &&
|
||||||
match.date.year == lastDayPlayed?.year &&
|
match.date.year == lastDayPlayed?.year &&
|
||||||
self.shouldCountMatch(match: match)
|
self.shouldCountMatch(match: match)
|
||||||
|
|
||||||
if let game = game {
|
if let game = game {
|
||||||
shouldInclude = shouldInclude && match.codGame == game
|
shouldInclude = shouldInclude && match.codGame == game
|
||||||
@@ -308,7 +341,7 @@ struct StatsController: RouteCollection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func getStatsForYear(year:Int, db: Database) -> EventLoopFuture<Stats>{
|
func getStatsForYear(year:Int, db: Database) -> EventLoopFuture<Stats>{
|
||||||
@@ -474,6 +507,11 @@ struct StatsController: RouteCollection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func getCasualStatsForGame( db: Database, gameId:String, afterDate:Date = Date(timeIntervalSince1970: 0)) -> EventLoopFuture<Stats>{
|
||||||
|
return Match.query(on: db).filter(\.$competitive == false).filter(\.$codGame == gameId).filter(\.$date > afterDate ).all().map { matches in
|
||||||
|
return Stats(totalWins: matches.filter{$0.win == true}.count, totalLosses: matches.filter{$0.win == false}.count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -629,12 +667,15 @@ struct StatsController: RouteCollection {
|
|||||||
|
|
||||||
|
|
||||||
let casualOverall = getCasualStats(db: db)
|
let casualOverall = getCasualStats(db: db)
|
||||||
|
let bocwCasual = getCasualStatsForGame(db: db, gameId: "bocw")
|
||||||
|
let vgCasual = getCasualStatsForGame(db: db, gameId: "vg", afterDate: Date(timeIntervalSince1970: 1635823473)) //nov 21 to exlude beta time in sept
|
||||||
|
|
||||||
|
|
||||||
let matches = Match.query(on: db).sort( \.$date).all()
|
let matches = Match.query(on: db).sort( \.$date).all()
|
||||||
|
|
||||||
return matches.and(hyderStats).and(statsFor2020).and(statsFor2021).and(casualOverall).map { arg -> ([String:Stats]) in
|
return matches.and(hyderStats).and(statsFor2020).and(statsFor2021).and(casualOverall).and(bocwCasual).and(vgCasual).map { arg -> ([String:Stats]) in
|
||||||
|
|
||||||
let ((((matches, hyderStats), statsFor2020), statsFor2021), casualOverall) = arg
|
let ((((((matches, hyderStats), statsFor2020), statsFor2021), casualOverall), bocwCasual), vgCasual) = arg
|
||||||
|
|
||||||
//print ("got matches \(Date().timeIntervalSince(startTime))")
|
//print ("got matches \(Date().timeIntervalSince(startTime))")
|
||||||
|
|
||||||
@@ -651,10 +692,12 @@ struct StatsController: RouteCollection {
|
|||||||
var overallFourPlayers:Stats?
|
var overallFourPlayers:Stats?
|
||||||
var blackOpsColdWarNuketownHalloween:Stats?
|
var blackOpsColdWarNuketownHalloween:Stats?
|
||||||
|
|
||||||
// var mapStats:[Int:Stats]?
|
|
||||||
// var worstMap:Int?
|
|
||||||
// var bestMap:Int?
|
// var mapStats:[Int:Stats]?
|
||||||
//
|
// var worstMap:Int?
|
||||||
|
// var bestMap:Int?
|
||||||
|
//
|
||||||
group.enter()
|
group.enter()
|
||||||
queue.async {
|
queue.async {
|
||||||
overallStats = self.getStatsWithMostRecentDailyRecord(sortedMatches: matches)
|
overallStats = self.getStatsWithMostRecentDailyRecord(sortedMatches: matches)
|
||||||
@@ -724,9 +767,8 @@ struct StatsController: RouteCollection {
|
|||||||
"mw_five_players":Stats(totalWins: mwFivePlayers!.totalWins, totalLosses: mwFivePlayers!.totalLosses),
|
"mw_five_players":Stats(totalWins: mwFivePlayers!.totalWins, totalLosses: mwFivePlayers!.totalLosses),
|
||||||
"overall":Stats(totalWins: overallStats!.totalWins, totalLosses: overallStats!.totalLosses),
|
"overall":Stats(totalWins: overallStats!.totalWins, totalLosses: overallStats!.totalLosses),
|
||||||
"casual_overall":Stats(totalWins: casualOverall.totalWins, totalLosses: casualOverall.totalLosses),
|
"casual_overall":Stats(totalWins: casualOverall.totalWins, totalLosses: casualOverall.totalLosses),
|
||||||
|
"bocw_casual":Stats(totalWins: bocwCasual.totalWins, totalLosses: bocwCasual.totalLosses),
|
||||||
|
"vg_casual":Stats(totalWins: vgCasual.totalWins, totalLosses: vgCasual.totalLosses),
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,7 +782,7 @@ struct StatsController: RouteCollection {
|
|||||||
|
|
||||||
let matches = Match.query(on: db).sort( \.$date).all()
|
let matches = Match.query(on: db).sort( \.$date).all()
|
||||||
|
|
||||||
let mapConfigs = getMapConfigs(db: db)
|
let mapConfigs = getMapConfigs(db: db)
|
||||||
|
|
||||||
|
|
||||||
return matches.and(dashboardStats).and(mapConfigs).map { arg -> (OverallStats) in
|
return matches.and(dashboardStats).and(mapConfigs).map { arg -> (OverallStats) in
|
||||||
@@ -755,28 +797,28 @@ struct StatsController: RouteCollection {
|
|||||||
var worstMap:Int?
|
var worstMap:Int?
|
||||||
var bestMap:Int?
|
var bestMap:Int?
|
||||||
|
|
||||||
//
|
//
|
||||||
group.enter()
|
group.enter()
|
||||||
queue.async {
|
queue.async {
|
||||||
mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
||||||
//print ("maps done \(Date().timeIntervalSince(startTime))")
|
//print ("maps done \(Date().timeIntervalSince(startTime))")
|
||||||
group.leave()
|
group.leave()
|
||||||
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
group.enter()
|
group.enter()
|
||||||
queue.async {
|
queue.async {
|
||||||
let mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
let mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
||||||
|
|
||||||
bestMap = self.getBestMap(records: mapStats)
|
bestMap = self.getBestMap(records: mapStats)
|
||||||
group.leave()
|
group.leave()
|
||||||
}
|
}
|
||||||
|
|
||||||
group.enter()
|
group.enter()
|
||||||
queue.async {
|
queue.async {
|
||||||
let mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
let mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
||||||
|
|
||||||
worstMap = self.getWorstMap(records: mapStats)
|
worstMap = self.getWorstMap(records: mapStats)
|
||||||
group.leave()
|
group.leave()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,14 +826,14 @@ struct StatsController: RouteCollection {
|
|||||||
|
|
||||||
let dashboardItems:[DashboardItem] =
|
let dashboardItems:[DashboardItem] =
|
||||||
|
|
||||||
(dashboardStats.dashboardItems +
|
(dashboardStats.dashboardItems +
|
||||||
[
|
[
|
||||||
DashboardItem(codTrackerId:"best_map_overall", title: "Best Map", content: mapConfigs.first{$0.mapId == bestMap}?.name ?? "error", title2: "Ratio", content2: "\(mapStats![bestMap!]!.winLossRatio) \(mapStats![bestMap!]!.record)", sortOrder: 12),
|
DashboardItem(codTrackerId:"best_map_overall", title: "Best Map", content: mapConfigs.first{$0.mapId == bestMap}?.name ?? "error", title2: "Ratio", content2: "\(mapStats![bestMap!]!.winLossRatio) \(mapStats![bestMap!]!.record)", sortOrder: 12),
|
||||||
DashboardItem(codTrackerId:"worst_map_overall", title: "Worst Map", content: mapConfigs.first{$0.mapId == worstMap}?.name ?? "error", title2: "Ratio", content2: "\(mapStats![worstMap!]!.winLossRatio) \(mapStats![worstMap!]!.record)",sortOrder: 13),
|
DashboardItem(codTrackerId:"worst_map_overall", title: "Worst Map", content: mapConfigs.first{$0.mapId == worstMap}?.name ?? "error", title2: "Ratio", content2: "\(mapStats![worstMap!]!.winLossRatio) \(mapStats![worstMap!]!.record)",sortOrder: 13),
|
||||||
|
|
||||||
]).sorted{
|
]).sorted{
|
||||||
$0.sortOrder < $1.sortOrder
|
$0.sortOrder < $1.sortOrder
|
||||||
}
|
}
|
||||||
return OverallStats(dashboardItems: dashboardItems)
|
return OverallStats(dashboardItems: dashboardItems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -828,12 +870,12 @@ struct StatsController: RouteCollection {
|
|||||||
if let game = req.parameters.get("game", as: String.self),
|
if let game = req.parameters.get("game", as: String.self),
|
||||||
let competitive = req.parameters.get("competitive", as:Bool.self) {
|
let competitive = req.parameters.get("competitive", as:Bool.self) {
|
||||||
|
|
||||||
let gameMode = req.parameters.get("gamemode", as:Int.self) ?? -2
|
let gameMode = req.parameters.get("gamemode", as:Int.self) ?? -2
|
||||||
mapStats = self.getMapStats(matches: matches,game: game, competitive: competitive, gameMode: gameMode)
|
mapStats = self.getMapStats(matches: matches,game: game, competitive: competitive, gameMode: gameMode)
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -852,49 +894,49 @@ struct StatsController: RouteCollection {
|
|||||||
loss = loss + Double(record.stats.totalLosses)
|
loss = loss + Double(record.stats.totalLosses)
|
||||||
|
|
||||||
}
|
}
|
||||||
return records
|
return records
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// return Match.query(on: req.db).all().map { (matches) -> [MapRecord] in
|
// return Match.query(on: req.db).all().map { (matches) -> [MapRecord] in
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// let mapStats:[Int:Stats]
|
// let mapStats:[Int:Stats]
|
||||||
//
|
//
|
||||||
// if let game = req.parameters.get("game", as: String.self),
|
// if let game = req.parameters.get("game", as: String.self),
|
||||||
// let competitive = req.parameters.get("competitive", as:Bool.self) {
|
// let competitive = req.parameters.get("competitive", as:Bool.self) {
|
||||||
//
|
//
|
||||||
// let gameMode = req.parameters.get("gamemode", as:Int.self) ?? -2
|
// let gameMode = req.parameters.get("gamemode", as:Int.self) ?? -2
|
||||||
// mapStats = self.getMapStats(matches: matches,game: game, competitive: competitive, gameMode: gameMode)
|
// mapStats = self.getMapStats(matches: matches,game: game, competitive: competitive, gameMode: gameMode)
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
// mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
// mapStats = self.getMapStats(matches: matches,game: "mw", competitive: true)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// let sortedMaps = self.mapsSortedByBest(records: mapStats)
|
// let sortedMaps = self.mapsSortedByBest(records: mapStats)
|
||||||
//
|
//
|
||||||
// let records = sortedMaps.map { (mapId) -> MapRecord in
|
// let records = sortedMaps.map { (mapId) -> MapRecord in
|
||||||
// return MapRecord(map: MapData.allMaps[mapId]!, stats: mapStats[mapId]!, ratio:mapStats[mapId]!.winLossRatio)
|
// return MapRecord(map: MapData.allMaps[mapId]!, stats: mapStats[mapId]!, ratio:mapStats[mapId]!.winLossRatio)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// var wins:Double = 0
|
// var wins:Double = 0
|
||||||
// var loss:Double = 0
|
// var loss:Double = 0
|
||||||
//
|
//
|
||||||
// for record in records {
|
// for record in records {
|
||||||
// //print("\(record.map.name) \(record.stats.record) \(record.ratio)")
|
// //print("\(record.map.name) \(record.stats.record) \(record.ratio)")
|
||||||
// wins = wins + Double(record.stats.totalWins)
|
// wins = wins + Double(record.stats.totalWins)
|
||||||
// loss = loss + Double(record.stats.totalLosses)
|
// loss = loss + Double(record.stats.totalLosses)
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// return records
|
// return records
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
func mapsSortedByBest (records :[ Int:Stats] ) -> [ Int ] {
|
func mapsSortedByBest (records :[ Int:Stats] ) -> [ Int ] {
|
||||||
@@ -904,16 +946,16 @@ struct StatsController: RouteCollection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getCountedMatchesByPlayerCount(matches:[Match], playerCount:Int) -> Stats {
|
func getCountedMatchesByPlayerCount(matches:[Match], playerCount:Int) -> Stats {
|
||||||
return getCountedMatches(matches: matches.filter{$0.playerList.count == playerCount})
|
return getCountedMatches(matches: matches.filter{$0.playerList.count == playerCount})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRecordForMapId(matches:[Match], mapId:String) -> Stats {
|
func getRecordForMapId(matches:[Match], mapId:String) -> Stats {
|
||||||
return getAllMatches(matches: matches.filter{$0.map == mapId})
|
return getAllMatches(matches: matches.filter{$0.map == mapId})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func getAllMatchesByPlayerCount(matches:[Match], playerCount:Int) -> Stats {
|
func getAllMatchesByPlayerCount(matches:[Match], playerCount:Int) -> Stats {
|
||||||
return getAllMatches(matches: matches.filter{$0.playerList.count == playerCount})
|
return getAllMatches(matches: matches.filter{$0.playerList.count == playerCount})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBestMap (records :[ Int:Stats] ) -> Int {
|
func getBestMap (records :[ Int:Stats] ) -> Int {
|
||||||
@@ -966,12 +1008,12 @@ struct StatsController: RouteCollection {
|
|||||||
if let map = match.map, let mapInt = Int(map) {
|
if let map = match.map, let mapInt = Int(map) {
|
||||||
|
|
||||||
if mapStats[mapInt] == nil {
|
if mapStats[mapInt] == nil {
|
||||||
mapStats[mapInt] = Stats(totalWins: 0, totalLosses: 0)
|
mapStats[mapInt] = Stats(totalWins: 0, totalLosses: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if match.win {
|
if match.win {
|
||||||
|
|
||||||
mapStats[mapInt]?.totalWins += 1
|
mapStats[mapInt]?.totalWins += 1
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
mapStats[mapInt]?.totalLosses += 1
|
mapStats[mapInt]?.totalLosses += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user