mw2 general stats
This commit is contained in:
@@ -35,7 +35,7 @@ struct StatsController: RouteCollection {
|
|||||||
func dashboard(db: Database) throws -> EventLoopFuture<DashboardStats> {
|
func dashboard(db: Database) throws -> EventLoopFuture<DashboardStats> {
|
||||||
let statistics = WinLossRecords.query(on: db).all()
|
let statistics = WinLossRecords.query(on: db).all()
|
||||||
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()
|
||||||
|
|
||||||
|
|
||||||
let colourSchemeConfigs = ColourScheme.query(on: db).all().map { colourScheme in
|
let colourSchemeConfigs = ColourScheme.query(on: db).all().map { colourScheme in
|
||||||
@@ -44,9 +44,9 @@ struct StatsController: RouteCollection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (statistics.and(adamAffectedMatches).and(totalMWGames).and(colourSchemeConfigs)).map { arg -> (DashboardStats) in
|
return (statistics.and(adamAffectedMatches).and(colourSchemeConfigs)).map { arg -> (DashboardStats) in
|
||||||
|
|
||||||
let ((((statistics, adamAffectedMatches), totalMWGames),colors)) = arg
|
let (((statistics, adamAffectedMatches),colors)) = arg
|
||||||
|
|
||||||
|
|
||||||
// return statistics.map { statistics in
|
// return statistics.map { statistics in
|
||||||
@@ -65,7 +65,6 @@ 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 = 100
|
sortOrder = 100
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if statisticItem.codTrackerId == "mw_overall"{
|
else if statisticItem.codTrackerId == "mw_overall"{
|
||||||
@@ -74,9 +73,8 @@ struct StatsController: RouteCollection {
|
|||||||
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
|
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)"
|
||||||
@@ -84,7 +82,6 @@ struct StatsController: RouteCollection {
|
|||||||
sortOrder = 60
|
sortOrder = 60
|
||||||
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if statisticItem.codTrackerId == "2021_overall"{
|
else if statisticItem.codTrackerId == "2021_overall"{
|
||||||
title2 = "Ratio"
|
title2 = "Ratio"
|
||||||
@@ -176,6 +173,22 @@ struct StatsController: RouteCollection {
|
|||||||
backgroundColor = colors.first(where: {$0.gameId == "vg"})?.tileColour ?? backgroundColor
|
backgroundColor = colors.first(where: {$0.gameId == "vg"})?.tileColour ?? backgroundColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if statisticItem.codTrackerId == "mw2_casual"{
|
||||||
|
title2 = "Ratio"
|
||||||
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
|
sortOrder = -82
|
||||||
|
backgroundColor = colors.first(where: {$0.gameId == "mw2"})?.tileColour ?? backgroundColor
|
||||||
|
}
|
||||||
|
|
||||||
|
else if statisticItem.codTrackerId == "mw2_competitive"{
|
||||||
|
title2 = "Ratio"
|
||||||
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
|
sortOrder = -83
|
||||||
|
backgroundColor = colors.first(where: {$0.gameId == "mw2"})?.tileColour ?? backgroundColor
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@@ -185,10 +198,7 @@ struct StatsController: RouteCollection {
|
|||||||
} ) +
|
} ) +
|
||||||
[
|
[
|
||||||
DashboardItem(codTrackerId: "adam_ruined_final_kills", title: "Final Kills Ruined by Adam", content: "\(adamAffectedMatches + 7)", title2: "", content2: "",sortOrder: 1000, backgroundColor: "484848"),
|
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}
|
).sorted{$0.sortOrder < $1.sortOrder}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user