|
|
|
|
@ -14,7 +14,7 @@ class ReportGenerator { |
|
|
|
|
|
|
|
|
|
static private let winnersDirectoryName: String = "reports/winners" |
|
|
|
|
|
|
|
|
|
static func go() { |
|
|
|
|
func go() { |
|
|
|
|
|
|
|
|
|
let realm = try! Realm() |
|
|
|
|
try! realm.write { |
|
|
|
|
@ -23,15 +23,16 @@ class ReportGenerator { |
|
|
|
|
|
|
|
|
|
Seed.createTournaments() |
|
|
|
|
Importer.start() |
|
|
|
|
ReportGenerator.create() |
|
|
|
|
self.create() |
|
|
|
|
self.writeHTML() |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static func createDirectories() { |
|
|
|
|
func createDirectories() { |
|
|
|
|
|
|
|
|
|
// Create winners directory if necessary |
|
|
|
|
if let docDirectory = FileUtils.documentsDirectoryPath { |
|
|
|
|
let winnersDirectory = docDirectory.appendingPathComponent(winnersDirectoryName) |
|
|
|
|
let winnersDirectory = docDirectory.appendingPathComponent(ReportGenerator.winnersDirectoryName) |
|
|
|
|
var isDir: ObjCBool = true |
|
|
|
|
if !FileManager.default.fileExists(atPath: winnersDirectory.absoluteString, isDirectory: &isDir) { |
|
|
|
|
do { |
|
|
|
|
@ -44,19 +45,42 @@ class ReportGenerator { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static func create() { |
|
|
|
|
fileprivate var _biggestWinners: [CumulatedResults] = [] |
|
|
|
|
fileprivate var _mostCashes: [CumulatedResults] = [] |
|
|
|
|
fileprivate var _tournamentWinners: [TournamentWinner] = [] |
|
|
|
|
fileprivate var _tourniesByEntries: [TournamentRepresentable] = [] |
|
|
|
|
fileprivate var _tourniesByPrizepool: [TournamentRepresentable] = [] |
|
|
|
|
fileprivate var _winsByCountry: [CountryCounter] = [] |
|
|
|
|
fileprivate var _cashesByCountry: [CountryCounter] = [] |
|
|
|
|
fileprivate var _averageEvent: [TournamentStats] = [] |
|
|
|
|
fileprivate var _notablesMostCashes: [CumulatedResults] = [] |
|
|
|
|
fileprivate var _averageCash: [CumulatedResults] = [] |
|
|
|
|
fileprivate var _tournamentBuyinDistribution: [DistributionCounter] = [] |
|
|
|
|
fileprivate var _tournamentPrizepoolDistribution: [DistributionCounter] = [] |
|
|
|
|
fileprivate var _firstPrizeDistribution: [DistributionCounter] = [] |
|
|
|
|
fileprivate var _holdemTournamentsDistribution: [DistributionCounter] = [] |
|
|
|
|
|
|
|
|
|
func create() { |
|
|
|
|
|
|
|
|
|
self.createDirectories() |
|
|
|
|
|
|
|
|
|
let realm = try! Realm() |
|
|
|
|
|
|
|
|
|
Queries.biggestWinners(realm: realm).writeHTML(fileName: "reports/earningsLeaderboard.html") |
|
|
|
|
Queries.mostCashes(realm: realm).writeHTML(fileName: "reports/mostCashes.html", limit: 25) |
|
|
|
|
self._biggestWinners = Queries.biggestWinners(realm: realm) |
|
|
|
|
self._mostCashes = Queries.mostCashes(realm: realm) |
|
|
|
|
self._tournamentWinners = Queries.allWinnersSortedByEvent(realm: realm) |
|
|
|
|
self._tourniesByEntries = Queries.sortedEvents(realm: realm, fieldName: "entries", ascending: false) |
|
|
|
|
self._tourniesByPrizepool = Queries.sortedEvents(realm: realm, fieldName: "prizepool", ascending: false) |
|
|
|
|
self._winsByCountry = Queries.winsByCountry(realm: realm) |
|
|
|
|
self._cashesByCountry = Queries.cashesByCountry(realm: realm) |
|
|
|
|
self._averageEvent = Queries.averageEvent(realm: realm) |
|
|
|
|
self._notablesMostCashes = Queries.mostCashes(realm: realm, notable: true) |
|
|
|
|
self._averageCash = Queries.averageCash(realm: realm) |
|
|
|
|
self._tournamentBuyinDistribution = Queries.tournamentBuyinDistribution(realm: realm) |
|
|
|
|
self._tournamentPrizepoolDistribution = Queries.tournamentPrizepoolDistribution(realm: realm) |
|
|
|
|
self._firstPrizeDistribution = Queries.firstPrizeDistribution(realm: realm) |
|
|
|
|
self._holdemTournamentsDistribution = Queries.holdemTournamentsDistribution(realm: realm) |
|
|
|
|
|
|
|
|
|
let tournamentWinners = Queries.allWinnersSortedByEvent(realm: realm) |
|
|
|
|
tournamentWinners.writeHTML(fileName: "reports/allWinners.html", limit: nil) |
|
|
|
|
tournamentWinners.writeHTML(fileName: "reports/allWinners_top10.html", limit: 10) |
|
|
|
|
|
|
|
|
|
let tourniesDate = realm.objects(Tournament.self).distinct(by: ["date"]) |
|
|
|
|
|
|
|
|
|
// Individual days |
|
|
|
|
@ -71,25 +95,30 @@ class ReportGenerator { |
|
|
|
|
notableCashes.writeHTML(fileName: "reports/winners/notables_\(fileDate).html") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let tourniesByEntries = Queries.sortedEvents(realm: realm, fieldName: "entries", ascending: false) |
|
|
|
|
tourniesByEntries.writeHTML(fileName: "reports/tourniesByEntries.html", limit: nil) |
|
|
|
|
tourniesByEntries.writeHTML(fileName: "reports/tourniesByEntries_top5.html", limit: 5) |
|
|
|
|
let tourniesByPrizepool = Queries.sortedEvents(realm: realm, fieldName: "prizepool", ascending: false) |
|
|
|
|
tourniesByPrizepool.writeHTML(fileName: "reports/tourniesByPrizepool.html", limit: nil) |
|
|
|
|
tourniesByPrizepool.writeHTML(fileName: "reports/tourniesByPrizepool_top5.html", limit: 5) |
|
|
|
|
|
|
|
|
|
Queries.winsByCountry(realm: realm).writeHTML(fileName: "reports/countryWins.html") |
|
|
|
|
Queries.cashesByCountry(realm: realm).writeHTML(fileName: "reports/countryCashes.html") |
|
|
|
|
Queries.averageEvent(realm: realm).writeHTML(fileName: "reports/averageEvent.html") |
|
|
|
|
Queries.mostCashes(realm: realm, notable: true).writeHTML(fileName: "reports/notablesMostCashes.html", limit: nil) |
|
|
|
|
Queries.averageCash(realm: realm).writeHTML(fileName: "reports/bestAverageCashes.html", limit: 5) |
|
|
|
|
Queries.tournamentBuyinDistribution(realm: realm).writeHTML(fileName: "reports/buyinDistribution.html") |
|
|
|
|
Queries.tournamentPrizepoolDistribution(realm: realm).writeHTML(fileName: "reports/prizepoolDistribution.html") |
|
|
|
|
Queries.firstPrizeDistribution(realm: realm).writeHTML(fileName: "reports/firstPrizeDistribution.html") |
|
|
|
|
Queries.holdemTournamentsDistribution(realm: realm).writeHTML(fileName: "reports/holdemDistribution.html") |
|
|
|
|
|
|
|
|
|
print("total player count = \(realm.objects(Player.self).count)") // 16203, 16129 |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fileprivate func writeHTML() { |
|
|
|
|
self._biggestWinners.writeHTML(fileName: "reports/earningsLeaderboard.html") |
|
|
|
|
self._mostCashes.writeHTML(fileName: "reports/mostCashes.html", limit: 25) |
|
|
|
|
self._tournamentWinners.writeHTML(fileName: "reports/allWinners.html", limit: nil) |
|
|
|
|
self._tournamentWinners.writeHTML(fileName: "reports/allWinners_top10.html", limit: 10) |
|
|
|
|
self._tourniesByEntries.writeHTML(fileName: "reports/tourniesByEntries.html", limit: nil) |
|
|
|
|
self._tourniesByEntries.writeHTML(fileName: "reports/tourniesByEntries_top5.html", limit: 5) |
|
|
|
|
self._tourniesByPrizepool.writeHTML(fileName: "reports/tourniesByPrizepool.html", limit: nil) |
|
|
|
|
self._tourniesByPrizepool.writeHTML(fileName: "reports/tourniesByPrizepool_top5.html", limit: 5) |
|
|
|
|
self._winsByCountry.writeHTML(fileName: "reports/countryWins.html") |
|
|
|
|
self._cashesByCountry.writeHTML(fileName: "reports/countryCashes.html") |
|
|
|
|
self._averageEvent.writeHTML(fileName: "reports/averageEvent.html") |
|
|
|
|
self._notablesMostCashes.writeHTML(fileName: "reports/notablesMostCashes.html", limit: nil) |
|
|
|
|
self._averageCash.writeHTML(fileName: "reports/bestAverageCashes.html", limit: 5) |
|
|
|
|
self._tournamentBuyinDistribution.writeHTML(fileName: "reports/buyinDistribution.html") |
|
|
|
|
self._tournamentPrizepoolDistribution.writeHTML(fileName: "reports/prizepoolDistribution.html") |
|
|
|
|
self._firstPrizeDistribution.writeHTML(fileName: "reports/firstPrizeDistribution.html") |
|
|
|
|
self._holdemTournamentsDistribution.writeHTML(fileName: "reports/holdemDistribution.html") |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|