diff --git a/TournamentStats/AppDelegate.swift b/TournamentStats/AppDelegate.swift index f9901c7..8d0b045 100644 --- a/TournamentStats/AppDelegate.swift +++ b/TournamentStats/AppDelegate.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 } diff --git a/TournamentStats/Importer.swift b/TournamentStats/Importer.swift index 7b3d73d..e24e226 100644 --- a/TournamentStats/Importer.swift +++ b/TournamentStats/Importer.swift @@ -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 { diff --git a/TournamentStats/report/Queries.swift b/TournamentStats/report/Queries.swift index 4c5319e..e874ab4 100644 --- a/TournamentStats/report/Queries.swift +++ b/TournamentStats/report/Queries.swift @@ -241,5 +241,25 @@ class Queries { } return counters } + + static func holdemTournamentsDistribution(realm: Realm) -> [DistributionCounter] { + + let tournaments: Results = 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 + } + } diff --git a/TournamentStats/report/ReportGenerator.swift b/TournamentStats/report/ReportGenerator.swift index f7ff705..cb96e0f 100644 --- a/TournamentStats/report/ReportGenerator.swift +++ b/TournamentStats/report/ReportGenerator.swift @@ -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")