fixed bug in halloween map count

This commit is contained in:
Michael Simard
2021-10-19 07:14:13 -05:00
parent 3c9bee293c
commit b0b0b7bc60
2 changed files with 16 additions and 22 deletions

View File

@@ -6,8 +6,6 @@
// //
import Foundation import Foundation
import Fluent import Fluent
import Vapor import Vapor
@@ -88,7 +86,6 @@ final class MonthStats: Content {
self.stats = stats self.stats = stats
} }
} }
@@ -123,11 +120,8 @@ final class Stats: Content {
func getRatioDouble() -> Double { func getRatioDouble() -> Double {
let deno = (totalLosses != 0) ? totalLosses : 1 let deno = (totalLosses != 0) ? totalLosses : 1
return (Double(totalWins) / Double(deno)).truncate(places: 3) return (Double(totalWins) / Double(deno)).truncate(places: 3)
} }
} }
final class StatsWithMostRecentDailyRecord: Content { final class StatsWithMostRecentDailyRecord: Content {

View File

@@ -57,21 +57,21 @@ struct StatsController: RouteCollection {
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 = 10 sortOrder = 100
} }
else if statisticItem.codTrackerId == "mw_overall"{ else if statisticItem.codTrackerId == "mw_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 = 2 sortOrder = 20
} }
else if statisticItem.codTrackerId == "mw_six_players"{ else if statisticItem.codTrackerId == "mw_six_players"{
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 = 6 sortOrder = 60
} }
@@ -79,34 +79,34 @@ struct StatsController: RouteCollection {
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 = 5 sortOrder = 50
} }
else if statisticItem.codTrackerId == "bocw_overall"{ else if statisticItem.codTrackerId == "bocw_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 = 3 sortOrder = 30
} }
else if statisticItem.codTrackerId == "with_hyder_overall"{ else if statisticItem.codTrackerId == "with_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 = 11 sortOrder = 110
} }
else if statisticItem.codTrackerId == "mw_five_players"{ else if statisticItem.codTrackerId == "mw_five_players"{
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 = 7 sortOrder = 70
} }
else if statisticItem.codTrackerId == "casual_overall"{ else if statisticItem.codTrackerId == "casual_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 = 4 sortOrder = 40
} }
@@ -114,19 +114,19 @@ struct StatsController: RouteCollection {
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 = 8 sortOrder = 80
} }
else if statisticItem.codTrackerId == "overall"{ else if statisticItem.codTrackerId == "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 = 1 sortOrder = 10
} }
else if statisticItem.codTrackerId == "2020_overall"{ else if statisticItem.codTrackerId == "2020_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 = 9 sortOrder = 90
} }
@@ -134,7 +134,7 @@ struct StatsController: RouteCollection {
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 = -2 sortOrder = 41
} }
@@ -148,8 +148,8 @@ struct StatsController: RouteCollection {
DashboardItem(codTrackerId:statisticItem.codTrackerId, title: title, content: content1, title2: title2, content2: content2, sortOrder: sortOrder, backgroundColor: statisticItem.codTrackerId == "bocw_nuketown_halloween" ? "FFA500" : "004999") 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: 100), DashboardItem(codTrackerId: "adam_ruined_final_kills", title: "Final Kills Ruined by Adam", content: "\(adamAffectedMatches + 7)", title2: "", content2: "",sortOrder: 1000),
DashboardItem(codTrackerId:"total_mw_games", title: "Total MW Games", content: "\(totalMWGames)", title2: "", content2: "", sortOrder: -1), DashboardItem(codTrackerId:"total_mw_games", title: "Total MW Games", content: "\(totalMWGames)", title2: "", content2: "", sortOrder: -10),
] ]
).sorted{$0.sortOrder < $1.sortOrder} ).sorted{$0.sortOrder < $1.sortOrder}
) )
@@ -718,7 +718,7 @@ struct StatsController: RouteCollection {
group.enter() group.enter()
queue.async { queue.async {
blackOpsColdWarNuketownHalloween = self.getRecordForMapId(matches: matches.filter{$0.codGame == "bocw"}, mapId: "Nuketown Halloween") blackOpsColdWarNuketownHalloween = self.getRecordForMapId(matches: matches.filter{$0.codGame == "bocw"}, mapId: "69")
group.leave() group.leave()
} }
@@ -863,7 +863,7 @@ struct StatsController: RouteCollection {
} }
func getRecordForMapId(matches:[Match], mapId:String) -> Stats { func getRecordForMapId(matches:[Match], mapId:String) -> Stats {
return getCountedMatches(matches: matches.filter{$0.map == mapId}) return getAllMatches(matches: matches.filter{$0.map == mapId})
} }