updated casual stats
This commit is contained in:
@@ -473,6 +473,19 @@ struct StatsController: RouteCollection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func getCasualStats( db: Database) -> EventLoopFuture<Stats>{
|
||||||
|
|
||||||
|
return Match.query(on: db).filter(\.$competitive == false).all().map { matches in
|
||||||
|
return Stats(totalWins: matches.filter{$0.win == true}.count, totalLosses: matches.filter{$0.win == false}.count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func getStatsForDay(year:Int, month:Int, day:Int, req: Request) -> EventLoopFuture<Stats>{
|
func getStatsForDay(year:Int, month:Int, day:Int, req: Request) -> EventLoopFuture<Stats>{
|
||||||
|
|
||||||
let winCount = Match.query(on: req.db)
|
let winCount = Match.query(on: req.db)
|
||||||
@@ -624,11 +637,13 @@ struct StatsController: RouteCollection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let casualOverall = getCasualStats(db: db)
|
||||||
|
|
||||||
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).map { arg -> ([String:Stats]) in
|
return matches.and(hyderStats).and(statsFor2020).and(statsFor2021).and(casualOverall).map { arg -> ([String:Stats]) in
|
||||||
|
|
||||||
let (((matches, hyderStats), statsFor2020), statsFor2021) = arg
|
let ((((matches, hyderStats), statsFor2020), statsFor2021), casualOverall) = arg
|
||||||
|
|
||||||
//print ("got matches \(Date().timeIntervalSince(startTime))")
|
//print ("got matches \(Date().timeIntervalSince(startTime))")
|
||||||
|
|
||||||
@@ -725,7 +740,7 @@ struct StatsController: RouteCollection {
|
|||||||
return [
|
return [
|
||||||
"mw_overall":Stats(totalWins: mwStats!.totalWins, totalLosses: mwStats!.totalLosses),
|
"mw_overall":Stats(totalWins: mwStats!.totalWins, totalLosses: mwStats!.totalLosses),
|
||||||
"no_hyder_overall":Stats(totalWins: hyderStats[1].totalWins, totalLosses: hyderStats[1].totalLosses),
|
"no_hyder_overall":Stats(totalWins: hyderStats[1].totalWins, totalLosses: hyderStats[1].totalLosses),
|
||||||
"with_hyder_overall":Stats(totalWins:hyderStats[0].totalWins, totalLosses: hyderStats[0].totalWins),
|
"with_hyder_overall":Stats(totalWins:hyderStats[0].totalWins, totalLosses: hyderStats[0].totalLosses),
|
||||||
"bocw_overall":Stats(totalWins: bocwStats!.totalWins, totalLosses: bocwStats!.totalLosses),
|
"bocw_overall":Stats(totalWins: bocwStats!.totalWins, totalLosses: bocwStats!.totalLosses),
|
||||||
"2020_overall":Stats(totalWins: statsFor2020.totalWins, totalLosses: statsFor2020.totalLosses),
|
"2020_overall":Stats(totalWins: statsFor2020.totalWins, totalLosses: statsFor2020.totalLosses),
|
||||||
"2021_overall":Stats(totalWins: statsFor2021.totalWins, totalLosses: statsFor2021.totalLosses),
|
"2021_overall":Stats(totalWins: statsFor2021.totalWins, totalLosses: statsFor2021.totalLosses),
|
||||||
@@ -733,6 +748,8 @@ struct StatsController: RouteCollection {
|
|||||||
"overall_four_players":Stats(totalWins: overallFourPlayers!.totalWins, totalLosses: overallFourPlayers!.totalLosses),
|
"overall_four_players":Stats(totalWins: overallFourPlayers!.totalWins, totalLosses: overallFourPlayers!.totalLosses),
|
||||||
"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),
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -792,7 +809,6 @@ struct StatsController: RouteCollection {
|
|||||||
[
|
[
|
||||||
DashboardItem(codTrackerId:"best_map_overall", title: "Best Map", content: MapData.allMaps[bestMap!]?.name ?? "error", title2: "Ratio", content2: "\(mapStats![bestMap!]!.winLossRatio) \(mapStats![bestMap!]!.record)", sortOrder: 12),
|
DashboardItem(codTrackerId:"best_map_overall", title: "Best Map", content: MapData.allMaps[bestMap!]?.name ?? "error", title2: "Ratio", content2: "\(mapStats![bestMap!]!.winLossRatio) \(mapStats![bestMap!]!.record)", sortOrder: 12),
|
||||||
DashboardItem(codTrackerId:"worst_map_overall", title: "Worst Map", content: MapData.allMaps[worstMap!]?.name ?? "error", title2: "Ratio", content2: "\(mapStats![worstMap!]!.winLossRatio) \(mapStats![worstMap!]!.record)",sortOrder: 13),
|
DashboardItem(codTrackerId:"worst_map_overall", title: "Worst Map", content: MapData.allMaps[worstMap!]?.name ?? "error", title2: "Ratio", content2: "\(mapStats![worstMap!]!.winLossRatio) \(mapStats![worstMap!]!.record)",sortOrder: 13),
|
||||||
DashboardItem(codTrackerId:"adam_ruined_final_kills", title: "Final Kills Ruined by Adam", content: "\(matches.filter{$0.finalKillRuinedPlayerId == 6}.count + 7)", title2: "", content2: "",sortOrder: 14),
|
|
||||||
|
|
||||||
]).sorted{
|
]).sorted{
|
||||||
$0.sortOrder < $1.sortOrder
|
$0.sortOrder < $1.sortOrder
|
||||||
|
|||||||
Reference in New Issue
Block a user