Added report + cleanup

master
Laurent 6 years ago
parent 13607b741b
commit 7845f7cb9b
  1. 9
      TournamentStats/AppDelegate.swift
  2. 2
      TournamentStats/Importer.swift
  3. 20
      TournamentStats/report/Queries.swift
  4. 1
      TournamentStats/report/ReportGenerator.swift

@ -33,12 +33,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
config.deleteRealmIfMigrationNeeded = true
Realm.Configuration.defaultConfiguration = config
// let map = NSLocale.isoCountryCodes.map { (cc) -> (String, String) in
// return (cc, NSLocale.current.localizedString(forRegionCode: cc)!)
// }
// print("cc = \(map)")
print("start report generation...")
let s = Date()
ReportGenerator.go()
let d = Date().timeIntervalSince(s)
print("reports created in \(d)s")
return true
}

@ -26,7 +26,7 @@ class Importer {
let realm = try! Realm()
let tournaments = realm.objects(Tournament.self)
print("tournaments2 count = \(tournaments.count)")
print("Tournaments count = \(tournaments.count)")
try! realm.write {

@ -241,5 +241,25 @@ class Queries {
}
return counters
}
static func holdemTournamentsDistribution(realm: Realm) -> [DistributionCounter] {
let tournaments: Results<Tournament> = realm.objects(Tournament.self)
let holdem = DistributionCounter(name: "Hold'em")
let not = DistributionCounter(name: "Not Hold'em")
let games: [DistributionCounter] = [holdem, not]
tournaments.forEach { tournament in
if tournament.name.contains("Hold'em") {
holdem.increment()
} else {
not.increment()
}
}
return games
}
}

@ -86,6 +86,7 @@ class ReportGenerator {
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")

Loading…
Cancel
Save