Compare commits
10 Commits
9374175c50
...
d4a67dffe6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4a67dffe6 | ||
|
|
98a68d11ab | ||
|
|
8c3cd32bcf | ||
|
|
be1d430755 | ||
|
|
79f029b769 | ||
|
|
4630a20755 | ||
|
|
14184ac665 | ||
|
|
e2f6a1b73a | ||
|
|
2054181d49 | ||
|
|
2c5ea3a9d5 |
@@ -13,7 +13,7 @@ import Fluent
|
|||||||
import Vapor
|
import Vapor
|
||||||
|
|
||||||
struct ColorSchemeConfig: Content {
|
struct ColorSchemeConfig: Content {
|
||||||
var gameId: Int
|
var gameId: String
|
||||||
var tileColour: String?
|
var tileColour: String?
|
||||||
var winColour: String?
|
var winColour: String?
|
||||||
var lossColour: String?
|
var lossColour: String?
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ struct GameConfig: Content {
|
|||||||
var maps: [MapConfig]
|
var maps: [MapConfig]
|
||||||
var enabled:Bool
|
var enabled:Bool
|
||||||
var colours:ColorSchemeConfig?
|
var colours:ColorSchemeConfig?
|
||||||
|
var shortName:String
|
||||||
|
var imageName:String
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ struct AppDataController: RouteCollection {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
return GameConfig(gameId: game.gameId, name: game.name, maps: mapConfigs, enabled: game.enabled, colours: colourSchemeConfigs.first{game.gameId == "\($0.gameId)"})
|
return GameConfig(gameId: game.gameId, name: game.name, maps: mapConfigs, enabled: game.enabled, colours: colourSchemeConfigs.first{game.gameId == "\($0.gameId)"}, shortName: game.shortName, imageName: game.imageName)
|
||||||
})
|
})
|
||||||
return Configuration(games:gameConfigs, gameModes: gameModeConfigs, gameModeGroups: gameModeGroupConfigs, players: playerConfigs, lossReasons: lossReasonConfigs)
|
return Configuration(games:gameConfigs, gameModes: gameModeConfigs, gameModeGroups: gameModeGroupConfigs, players: playerConfigs, lossReasons: lossReasonConfigs)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,18 @@ 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()
|
||||||
|
|
||||||
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(colourSchemeConfigs)).map { arg -> (DashboardStats) in
|
||||||
|
|
||||||
|
let (((statistics, adamAffectedMatches),colors)) = arg
|
||||||
|
|
||||||
|
|
||||||
// return statistics.map { statistics in
|
// return statistics.map { statistics in
|
||||||
@@ -51,6 +58,7 @@ 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"
|
||||||
@@ -64,14 +72,15 @@ 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"{
|
||||||
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 = 60
|
sortOrder = 60
|
||||||
|
backgroundColor = colors.first(where: {$0.gameId == "mw"})?.tileColour ?? backgroundColor
|
||||||
|
|
||||||
}
|
}
|
||||||
else if statisticItem.codTrackerId == "2021_overall"{
|
else if statisticItem.codTrackerId == "2021_overall"{
|
||||||
@@ -86,6 +95,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 +109,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,21 +145,60 @@ 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 = colors.first(where: {$0.gameId == "bocw"})?.tileColour ?? backgroundColor
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 if statisticItem.codTrackerId == "vg_competitive"{
|
||||||
|
title2 = "Ratio"
|
||||||
|
content1 = "\(statisticItem.wins)-\(statisticItem.losses)"
|
||||||
|
content2 = Utils.getRatio(wins: statisticItem.wins, losses: statisticItem.losses)
|
||||||
|
sortOrder = -81
|
||||||
|
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 {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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),
|
|
||||||
]
|
]
|
||||||
).sorted{$0.sortOrder < $1.sortOrder}
|
).sorted{$0.sortOrder < $1.sortOrder}
|
||||||
)
|
)
|
||||||
@@ -474,6 +524,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 +684,16 @@ struct StatsController: RouteCollection {
|
|||||||
|
|
||||||
|
|
||||||
let casualOverall = getCasualStats(db: db)
|
let casualOverall = getCasualStats(db: db)
|
||||||
|
let bocwCasual = getCasualStatsForGame(db: db, gameId: "bocw")
|
||||||
|
let mw2Casual = getCasualStatsForGame(db: db, gameId: "mw2", afterDate: Date(timeIntervalSince1970: 1635823473))
|
||||||
|
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).and(mw2Casual).map { arg -> ([String:Stats]) in
|
||||||
|
|
||||||
let ((((matches, hyderStats), statsFor2020), statsFor2021), casualOverall) = arg
|
let (((((((matches, hyderStats), statsFor2020), statsFor2021), casualOverall), bocwCasual), vgCasual),mw2Casual) = arg
|
||||||
|
|
||||||
//print ("got matches \(Date().timeIntervalSince(startTime))")
|
//print ("got matches \(Date().timeIntervalSince(startTime))")
|
||||||
|
|
||||||
@@ -650,6 +709,10 @@ struct StatsController: RouteCollection {
|
|||||||
var mwFivePlayers:Stats?
|
var mwFivePlayers:Stats?
|
||||||
var overallFourPlayers:Stats?
|
var overallFourPlayers:Stats?
|
||||||
var blackOpsColdWarNuketownHalloween:Stats?
|
var blackOpsColdWarNuketownHalloween:Stats?
|
||||||
|
var vgCompetitive:StatsWithMostRecentDailyRecord?
|
||||||
|
var mw2Cometitive:StatsWithMostRecentDailyRecord?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// var mapStats:[Int:Stats]?
|
// var mapStats:[Int:Stats]?
|
||||||
// var worstMap:Int?
|
// var worstMap:Int?
|
||||||
@@ -709,6 +772,28 @@ struct StatsController: RouteCollection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
group.enter()
|
||||||
|
queue.async {
|
||||||
|
|
||||||
|
vgCompetitive = self.getStatsWithMostRecentDailyRecord(sortedMatches: matches.filter({ (match) -> Bool in
|
||||||
|
return match.codGame == "vg" && self.shouldCountMatch(match: match )
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
group.leave()
|
||||||
|
}
|
||||||
|
|
||||||
|
group.enter()
|
||||||
|
queue.async {
|
||||||
|
|
||||||
|
mw2Cometitive = self.getStatsWithMostRecentDailyRecord(sortedMatches: matches.filter({ (match) -> Bool in
|
||||||
|
return match.codGame == "mw2" && self.shouldCountMatch(match: match )
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
group.leave()
|
||||||
|
}
|
||||||
|
|
||||||
group.wait()
|
group.wait()
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -724,8 +809,11 @@ 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),
|
||||||
|
"vg_competitive":Stats(totalWins: vgCompetitive!.totalWins, totalLosses: vgCompetitive!.totalLosses),
|
||||||
|
"mw2_casual":Stats(totalWins: mw2Casual.totalWins, totalLosses: mw2Casual.totalLosses),
|
||||||
|
"mw2_competitive":Stats(totalWins: mw2Cometitive!.totalWins, totalLosses: mw2Cometitive!.totalLosses),
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ final class ColourScheme: Model, Content {
|
|||||||
var id: UUID?
|
var id: UUID?
|
||||||
|
|
||||||
@Field(key: "game_id")
|
@Field(key: "game_id")
|
||||||
var gameId: Int
|
var gameId: String
|
||||||
|
|
||||||
@Field(key: "tile_colour")
|
@Field(key: "tile_colour")
|
||||||
var tileColour: String?
|
var tileColour: String?
|
||||||
@@ -35,7 +35,7 @@ final class ColourScheme: Model, Content {
|
|||||||
init() { }
|
init() { }
|
||||||
|
|
||||||
// Creates a new with all properties set.
|
// Creates a new with all properties set.
|
||||||
init(id: UUID? = nil, gameId: Int, tileColour: String?,winColour: String?,lossColour: String? ) {
|
init(id: UUID? = nil, gameId: String, tileColour: String?,winColour: String?,lossColour: String? ) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.gameId = gameId
|
self.gameId = gameId
|
||||||
self.tileColour = tileColour
|
self.tileColour = tileColour
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ final class Game: Model, Content {
|
|||||||
@Field(key: "enabled")
|
@Field(key: "enabled")
|
||||||
var enabled: Bool
|
var enabled: Bool
|
||||||
|
|
||||||
|
@Field(key: "short_name")
|
||||||
|
var shortName: String
|
||||||
|
|
||||||
|
@Field(key: "image_name")
|
||||||
|
var imageName: String
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -38,12 +43,14 @@ final class Game: Model, Content {
|
|||||||
init() { }
|
init() { }
|
||||||
|
|
||||||
// Creates a new with all properties set.
|
// Creates a new with all properties set.
|
||||||
init(id: UUID? = nil, gameId: String, name: String, maps:String, enabled:Bool) {
|
init(id: UUID? = nil, gameId: String, name: String, maps:String, enabled:Bool, shortName:String, imageName:String) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.gameId = gameId
|
self.gameId = gameId
|
||||||
self.name = name
|
self.name = name
|
||||||
self.maps = maps
|
self.maps = maps
|
||||||
self.enabled = enabled
|
self.enabled = enabled
|
||||||
|
self.shortName = shortName
|
||||||
|
self.imageName = imageName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user