new stats
This commit is contained in:
@@ -37,9 +37,16 @@ struct StatsController: RouteCollection {
|
||||
let adamAffectedMatches = Match.query(on: db).filter(\.$finalKillRuinedPlayerId == 6).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
|
||||
@@ -51,12 +58,14 @@ struct StatsController: RouteCollection {
|
||||
var content1 = ""
|
||||
var content2 = ""
|
||||
var sortOrder = 0
|
||||
var backgroundColor = "484848"
|
||||
|
||||
if statisticItem.codTrackerId == "no_hyder_overall"{
|
||||
title2 = "Ratio"
|
||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||
sortOrder = 100
|
||||
|
||||
}
|
||||
|
||||
else if statisticItem.codTrackerId == "mw_overall"{
|
||||
@@ -64,6 +73,8 @@ struct StatsController: RouteCollection {
|
||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||
sortOrder = 20
|
||||
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
||||
|
||||
|
||||
}
|
||||
else if statisticItem.codTrackerId == "mw_six_players"{
|
||||
@@ -71,6 +82,7 @@ struct StatsController: RouteCollection {
|
||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||
sortOrder = 60
|
||||
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
||||
|
||||
|
||||
}
|
||||
@@ -86,6 +98,7 @@ struct StatsController: RouteCollection {
|
||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||
sortOrder = 30
|
||||
backgroundColor = colors.first(where: {$0.gameId == "bocw"})?.tileColour ?? backgroundColor
|
||||
|
||||
}
|
||||
else if statisticItem.codTrackerId == "with_hyder_overall"{
|
||||
@@ -99,6 +112,7 @@ struct StatsController: RouteCollection {
|
||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||
sortOrder = 70
|
||||
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
||||
|
||||
}
|
||||
else if statisticItem.codTrackerId == "casual_overall"{
|
||||
@@ -134,21 +148,40 @@ struct StatsController: RouteCollection {
|
||||
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||
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 {
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
DashboardItem(codTrackerId:statisticItem.codTrackerId, title: title, content: content1, title2: title2, content2: content2, sortOrder: sortOrder, backgroundColor: statisticItem.codTrackerId == "bocw_nuketown_halloween" ? "FFA500" : "004999")
|
||||
return DashboardItem(codTrackerId:statisticItem.codTrackerId, title: title, content: content1, title2: title2, content2: content2, sortOrder: sortOrder, backgroundColor:backgroundColor)
|
||||
} ) +
|
||||
[
|
||||
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: -10),
|
||||
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, backgroundColor: colors.first(where: {$0.gameId == "mw"})?.tileColour ?? "484848"
|
||||
|
||||
|
||||
),
|
||||
]
|
||||
).sorted{$0.sortOrder < $1.sortOrder}
|
||||
)
|
||||
@@ -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 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()
|
||||
|
||||
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))")
|
||||
|
||||
@@ -651,6 +692,8 @@ struct StatsController: RouteCollection {
|
||||
var overallFourPlayers:Stats?
|
||||
var blackOpsColdWarNuketownHalloween:Stats?
|
||||
|
||||
|
||||
|
||||
// var mapStats:[Int:Stats]?
|
||||
// var worstMap:Int?
|
||||
// var bestMap:Int?
|
||||
@@ -724,9 +767,8 @@ struct StatsController: RouteCollection {
|
||||
"mw_five_players":Stats(totalWins: mwFivePlayers!.totalWins, totalLosses: mwFivePlayers!.totalLosses),
|
||||
"overall":Stats(totalWins: overallStats!.totalWins, totalLosses: overallStats!.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),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user