diff --git a/TournamentStats/AppDelegate.swift b/TournamentStats/AppDelegate.swift
index 794cb13..74faa04 100644
--- a/TournamentStats/AppDelegate.swift
+++ b/TournamentStats/AppDelegate.swift
@@ -18,14 +18,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- for fontFamilyName in UIFont.familyNames {
- print("family: \(fontFamilyName)\n")
-
- for fontName in UIFont.fontNames(forFamilyName: fontFamilyName) {
- print("font: \(fontName)")
- }
- }
-
+// for fontFamilyName in UIFont.familyNames {
+// print("family: \(fontFamilyName)\n")
+//
+// for fontName in UIFont.fontNames(forFamilyName: fontFamilyName) {
+// print("font: \(fontName)")
+// }
+// }
// UI stuff
let splitViewController = window!.rootViewController as! UISplitViewController
@@ -45,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
print("start report generation...")
let s = Date()
let generator = ReportGenerator()
- generator.go(importData: false)
+ generator.go(importData: true)
let d = Date().timeIntervalSince(s)
print("reports created in \(d)s")
diff --git a/TournamentStats/Seed.swift b/TournamentStats/Seed.swift
index 1cbd32a..298e7f5 100644
--- a/TournamentStats/Seed.swift
+++ b/TournamentStats/Seed.swift
@@ -12,12 +12,33 @@ import RealmSwift
import Realm
struct TD {
+
+ init(date: String, name: String, number: Int, buyin: Int, entries: Int, prizePool: Double, tableSize: Int) {
+ self.date = date
+ self.name = name
+ self.number = number
+ self.buyin = buyin
+ self.entries = entries
+ self.prizePool = prizePool
+ self.tableSize = tableSize
+ }
+
+ init(date: String, name: String, number: Int, buyin: Int, entries: Int, prizePool: Double) {
+ self.date = date
+ self.name = name
+ self.number = number
+ self.buyin = buyin
+ self.entries = entries
+ self.prizePool = prizePool
+ }
+
var date: String = ""
var name: String = ""
var number: Int = 0
var buyin: Int = 0
var entries: Int = 0
var prizePool: Double = 0
+ var tableSize: Int = 9
}
class Seed {
@@ -80,7 +101,7 @@ class Seed {
TD(date: "26/06/2019", name: "No-Limit Hold'em Super Turbo Bounty", number: 56, buyin: 1500, entries: 1867, prizePool: 2520450),
TD(date: "27/06/2019", name: "Monster Stack No-Limit Hold'em", number: 50, buyin: 1500, entries: 6035, prizePool: 8147250),
TD(date: "27/06/2019", name: "Tag Team No-Limit Hold'em", number: 57, buyin: 1000, entries: 976, prizePool: 878400),
- TD(date: "29/06/2019", name: "Poker Players Championship", number: 58, buyin: 50000, entries: 74, prizePool: 3552000),
+ TD(date: "29/06/2019", name: "Poker Players Championship", number: 58, buyin: 50000, entries: 74, prizePool: 3552000, tableSize: 6),
TD(date: "29/06/2019", name: "No-Limit Hold'em DEEPSTACK CHAMPIONSHIP", number: 59, buyin: 600, entries: 6140, prizePool: 3223500),
TD(date: "29/06/2019", name: "Pot-Limit Omaha Hi/Lo 8 or Better", number: 60, buyin: 1500, entries: 1117, prizePool: 1507950),
TD(date: "30/06/2019", name: "Razz", number: 62, buyin: 10000, entries: 116, prizePool: 1090400),
@@ -127,6 +148,16 @@ class Seed {
for td in tournamentsDescriptions {
let event: Tournament = realm.create(Tournament.self)
event.name = td.name
+ event.tableSize = td.tableSize
+
+ if td.name.contains("6-Handed") {
+ event.tableSize = 6
+ } else if td.name.contains("8-Handed") {
+ event.tableSize = 8
+ } else if td.name.contains("Heads-Up") {
+ event.tableSize = 2
+ }
+
event.date = Formatter.basicDate.date(from: td.date) ?? Date()
event.number = td.number
event.buyin = td.buyin
diff --git a/TournamentStats/UI/reports/InfographyView.swift b/TournamentStats/UI/reports/InfographyView.swift
index d9c44a5..71e824c 100644
--- a/TournamentStats/UI/reports/InfographyView.swift
+++ b/TournamentStats/UI/reports/InfographyView.swift
@@ -31,8 +31,9 @@ class InfographyView: UIView {
@IBOutlet weak var tableView12: TableView!
@IBOutlet weak var tableView13: TableView!
- @IBOutlet weak var mostCollectionView: UICollectionView!
-
+ @IBOutlet weak var mostTableView: TableView!
+ @IBOutlet weak var mostTableView2: TableView!
+
@IBOutlet weak var hStack2a: UIStackView!
@IBOutlet weak var label21: UILabel!
@IBOutlet weak var label22: UILabel!
@@ -106,9 +107,11 @@ class InfographyView: UIView {
/////
- self.mostCollectionView.register(UINib(nibName: "StatCollectionViewCell", bundle: Bundle.main), forCellWithReuseIdentifier: "Stat")
- self.mostCollectionView.delegate = generator.rankings
- self.mostCollectionView.dataSource = generator.rankings
+ self.mostTableView.delegate = generator.rankings1
+ self.mostTableView.dataSource = generator.rankings1
+
+ self.mostTableView2.delegate = generator.rankings2
+ self.mostTableView2.dataSource = generator.rankings2
/////
diff --git a/TournamentStats/UI/reports/InfographyView.xib b/TournamentStats/UI/reports/InfographyView.xib
index 4fd90c9..be00f07 100644
--- a/TournamentStats/UI/reports/InfographyView.xib
+++ b/TournamentStats/UI/reports/InfographyView.xib
@@ -17,7 +17,7 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
-
+
@@ -85,7 +88,7 @@
-
+
@@ -101,7 +104,7 @@
-
+
-
+
@@ -137,7 +140,7 @@
-
+
@@ -145,7 +148,7 @@
-
+
@@ -157,7 +160,7 @@
-
+
@@ -165,7 +168,7 @@
-
+
@@ -177,7 +180,7 @@
-
+
@@ -185,7 +188,7 @@
-
+
-
+
@@ -221,7 +224,7 @@
-
+
-
+
@@ -298,7 +301,8 @@
-
+
+
diff --git a/TournamentStats/realm/Model.swift b/TournamentStats/realm/Model.swift
index 3cd5576..c33aca1 100644
--- a/TournamentStats/realm/Model.swift
+++ b/TournamentStats/realm/Model.swift
@@ -23,19 +23,7 @@ class Tournament : Object, Named {
@objc dynamic var number: Int = 0
@objc dynamic var buyin: Int = 0
@objc dynamic var tableSize: Int = 0
- @objc dynamic var name: String = "" {
- didSet {
- if name.contains("6-Handed") {
- self.tableSize = 6
- } else if name.contains("8-Handed") {
- self.tableSize = 8
- } else if name.contains("Heads-Up") {
- self.tableSize = 2
- } else {
- self.tableSize = 10
- }
- }
- }
+ @objc dynamic var name: String = ""
let results = List()
@objc dynamic var prizepool: Double = 0.0
@@ -50,6 +38,10 @@ class Tournament : Object, Named {
}
}
+ var formatted: String {
+ return "#\(self.number): \(self.buyin.currencyFormatted) \(self.name)"
+ }
+
}
class Player : Object, Named {
diff --git a/TournamentStats/report/Queries.swift b/TournamentStats/report/Queries.swift
index 15faf12..b01851e 100644
--- a/TournamentStats/report/Queries.swift
+++ b/TournamentStats/report/Queries.swift
@@ -316,7 +316,8 @@ class Queries {
case 2:
runnerUps.append(result)
default:
- if result.rank <= result.tournaments.first?.tableSize ?? 10 {
+ let tableSize: Int = result.tournaments.first?.tableSize ?? 9
+ if result.rank <= tableSize {
finalTables.append(result)
}
}
diff --git a/TournamentStats/report/ReportGenerator.swift b/TournamentStats/report/ReportGenerator.swift
index cf18bfb..1090f23 100644
--- a/TournamentStats/report/ReportGenerator.swift
+++ b/TournamentStats/report/ReportGenerator.swift
@@ -66,8 +66,9 @@ class ReportGenerator {
var tournamentPrizepoolDistribution: [DistributionCounter] = []
var firstPrizeDistribution: [DistributionCounter] = []
var gamesDistribution: [DistributionCounter] = []
- var rankings: PlayerNotableFinishesDataSource = PlayerNotableFinishesDataSource(notableFinishes: [])
-
+ var rankings1: PlayerNotableFinishesDataSource = PlayerNotableFinishesDataSource(notableFinishes: [], finalTables: false)
+ var rankings2: PlayerNotableFinishesDataSource = PlayerNotableFinishesDataSource(notableFinishes: [], finalTables: true)
+
func generateReports() {
self.createDirectories()
@@ -91,7 +92,8 @@ class ReportGenerator {
self.tournamentPrizepoolDistribution = Queries.tournamentPrizepoolDistribution(realm: realm)
self.firstPrizeDistribution = Queries.firstPrizeDistribution(realm: realm)
self.gamesDistribution = Queries.holdemTournamentsDistribution(realm: realm)
- self.rankings = PlayerNotableFinishesDataSource(notableFinishes: Queries.rankingCounts(realm: realm))
+ self.rankings1 = PlayerNotableFinishesDataSource(notableFinishes: Queries.rankingCounts(realm: realm), finalTables: false)
+ self.rankings2 = PlayerNotableFinishesDataSource(notableFinishes: Queries.rankingCounts(realm: realm), finalTables: true)
let tourniesDate = realm.objects(Tournament.self).distinct(by: ["date"])
diff --git a/TournamentStats/report/structures/PlayerNotableFinishes.swift b/TournamentStats/report/structures/PlayerNotableFinishes.swift
index 9e01c42..52b7b03 100644
--- a/TournamentStats/report/structures/PlayerNotableFinishes.swift
+++ b/TournamentStats/report/structures/PlayerNotableFinishes.swift
@@ -18,88 +18,168 @@ struct PlayerNotableFinishes {
}
-class PlayerNotableFinishesDataSource : NSObject, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
+class PlayerNotableFinishesDataSource : NSObject, UITableViewDataSource, UITableViewDelegate {
let notableFinishes: [PlayerNotableFinishes]
- let mostWins: [Player]
- let mostWinsCount: Int
- let mostRunnerUps: [Player]
- let mostRunnerUpsCount: Int
- let mostFinalTables: [Player]
- let mostFinalTablesCount: Int
+ var mostWins: [PlayerNotableFinishes] = []
+ var mostWinsCount: Int = 0
+ var mostRunnerUps: [PlayerNotableFinishes] = []
+ var mostRunnerUpsCount: Int = 0
+ var mostFinalTables: [PlayerNotableFinishes] = []
+ var mostFinalTablesCount: Int = 0
- init(notableFinishes: [PlayerNotableFinishes]) {
+ var winsDisplay: [(String, UIFont)] = []
+ var runnerUpsDisplay: [(String, UIFont)] = []
+
+ let finalTables: Bool
+
+ init(notableFinishes: [PlayerNotableFinishes], finalTables: Bool) {
self.notableFinishes = notableFinishes
+ self.finalTables = finalTables
- ///////
- var nWins = notableFinishes
- nWins.sort { (p1, p2) -> Bool in
- return p1.wins.count > p2.wins.count
- }
- let winsTopCount = nWins.first?.wins.count ?? 0
- self.mostWins = nWins.filter { $0.wins.count == winsTopCount}.map { $0.player }
-
- ///////
- var nRunnerups = notableFinishes
- nRunnerups.sort { (p1, p2) -> Bool in
- return p1.runnerUps.count > p2.runnerUps.count
- }
- let runnerUpsTopCount = nRunnerups.first?.runnerUps.count ?? 0
- self.mostRunnerUps = nRunnerups.filter { $0.runnerUps.count == runnerUpsTopCount}.map { $0.player }
-
- ///////
- var nFinalTables = notableFinishes
- nFinalTables.sort { (p1, p2) -> Bool in
- return p1.finalTables.count > p2.finalTables.count
+ if finalTables {
+
+ var nFinalTables = notableFinishes
+ nFinalTables.sort { (p1, p2) -> Bool in
+ return p1.finalTables.count > p2.finalTables.count
+ }
+ let finalTablesTopCount = nFinalTables.first?.finalTables.count ?? 0
+ self.mostFinalTables = nFinalTables.filter { $0.finalTables.count == finalTablesTopCount }
+
+ self.mostFinalTablesCount = finalTablesTopCount
+
+ } else {
+
+ var nWins = notableFinishes
+ nWins.sort { (p1, p2) -> Bool in
+ return p1.wins.count > p2.wins.count
+ }
+ let winsTopCount = nWins.first?.wins.count ?? 0
+ self.mostWins = nWins.filter { $0.wins.count == winsTopCount}
+
+ for win in self.mostWins {
+ self.winsDisplay.append((win.player.formattedName, Fonts.subTitle))
+ for result in win.wins {
+ if let tournamentName = result.tournaments.first?.formatted {
+ self.winsDisplay.append((" " + tournamentName, Fonts.regular))
+ } else {
+ self.winsDisplay.append(("no tournament!!!", Fonts.regular))
+ }
+ }
+ }
+
+ ///////
+ var nRunnerups = notableFinishes
+ nRunnerups.sort { (p1, p2) -> Bool in
+ return p1.runnerUps.count > p2.runnerUps.count
+ }
+ let runnerUpsTopCount = nRunnerups.first?.runnerUps.count ?? 0
+ self.mostRunnerUps = nRunnerups.filter { $0.runnerUps.count == runnerUpsTopCount }
+
+ for runnerup in self.mostRunnerUps {
+ self.runnerUpsDisplay.append((runnerup.player.formattedName, Fonts.subTitle))
+ for result in runnerup.runnerUps {
+ if let tournamentName = result.tournaments.first?.formatted {
+ self.runnerUpsDisplay.append((" " + tournamentName, Fonts.regular))
+ } else {
+ self.runnerUpsDisplay.append(("no tournament!!!", Fonts.regular))
+ }
+ }
+ }
+
+ self.mostWinsCount = winsTopCount
+ self.mostRunnerUpsCount = runnerUpsTopCount
}
- let finalTablesTopCount = nFinalTables.first?.finalTables.count ?? 0
- self.mostFinalTables = nFinalTables.filter { $0.finalTables.count == finalTablesTopCount}.map { $0.player }
- self.mostWinsCount = winsTopCount
- self.mostRunnerUpsCount = runnerUpsTopCount
- self.mostFinalTablesCount = finalTablesTopCount
+
}
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
- return 3
+ // MARK - Table
+
+ func numberOfSections(in tableView: UITableView) -> Int {
+ return self.finalTables ? 1 : 2
}
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Stat", for: indexPath) as! StatCollectionViewCell
-
- let name: String
- let value: String
- switch indexPath.row {
- case 0:
- name = "Most Wins"
- value = self.mostWins.map { $0.formattedName }.joined(separator: ", ") + " (\(self.mostWinsCount))"
- case 1:
- name = "Most Runner-up"
- value = self.mostRunnerUps.map { $0.formattedName }.joined(separator: ", ") + " (\(self.mostRunnerUpsCount))"
- case 2:
- name = "Most final tables"
- value = self.mostFinalTables.map { $0.formattedName }.joined(separator: ", ") + " (\(self.mostFinalTablesCount))"
- default:
- name = ""
- value = ""
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+ if self.finalTables {
+ return self.mostFinalTables.count
+ } else {
+ switch section {
+ case 0:
+ return self.winsDisplay.count
+ case 1:
+ return self.runnerUpsDisplay.count
+ default:
+ return self.mostFinalTables.count
+ }
}
+ }
+
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- cell.nameLabel.text = name.uppercased()
- cell.valueLabel.text = value
-
- cell.nameLabel.textColor = UIColor.white
- cell.valueLabel.textColor = UIColor.white
-
- cell.nameLabel.font = Fonts.regular
- cell.valueLabel.font = Fonts.bigNumbers
+ let cell = UITableViewCell()
+ cell.backgroundColor = UIColor.clear
+ cell.textLabel?.textColor = UIColor.white
+ let font: UIFont
+ let text: String
+ if self.finalTables {
+ text = self.mostFinalTables[indexPath.row].player.formattedName
+ font = Fonts.regular
+ } else {
+ switch indexPath.section {
+ case 0:
+ text = self.winsDisplay[indexPath.row].0
+ font = self.winsDisplay[indexPath.row].1
+ case 1:
+ text = self.runnerUpsDisplay[indexPath.row].0
+ font = self.runnerUpsDisplay[indexPath.row].1
+ case 2:
+ text = self.mostFinalTables[indexPath.row].player.formattedName
+ font = Fonts.regular
+ default:
+ text = "problem"
+ font = Fonts.regular
+ }
+ }
+ cell.textLabel?.text = text
+ cell.textLabel?.font = font
return cell
}
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
- return CGSize(width: 800.0, height: 90.0)
+ func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+ let text: String
+ if self.finalTables {
+ text = "Most final tables - \(self.mostFinalTablesCount)"
+ } else {
+ switch section {
+ case 0:
+ text = "Most wins - \(self.mostWinsCount) bracelets"
+ case 1:
+ text = "Most runner-ups - \(self.mostRunnerUpsCount)"
+ default:
+ text = "Most final tables - \(self.mostFinalTablesCount)"
+ }
+ }
+
+ return self.headerLabel(text: text)
+ }
+
+ func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
+ return 60.0
+ }
+
+ func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
+ return 40.0
+ }
+
+ func headerLabel(text: String) -> UILabel {
+ let label = UILabel(frame: CGRect(x: 0, y: 0, width: 500.0, height: 60.0))
+ label.textColor = UIColor.white
+ label.font = Fonts.subTitle
+ label.text = text
+ return label
}
}
diff --git a/TournamentStats/report/structures/TournamentRepresentable.swift b/TournamentStats/report/structures/TournamentRepresentable.swift
index 284a628..a3aa02d 100644
--- a/TournamentStats/report/structures/TournamentRepresentable.swift
+++ b/TournamentStats/report/structures/TournamentRepresentable.swift
@@ -13,11 +13,11 @@ struct TournamentRepresentable : HTMLRepresentable {
var tournament: Tournament
func columnDescriptors() -> [ColumnDescriptor] {
- return [ColumnDescriptor(header: "#", number: true, widthWeight: 0.3),
- ColumnDescriptor(header: "Buy-in", number: true, widthWeight: 0.5),
+ return [ColumnDescriptor(header: "#", number: true, widthWeight: 0.2),
+ ColumnDescriptor(header: "Buy-in", number: true, widthWeight: 0.4),
ColumnDescriptor(header: "Event", number: false, widthWeight: 2.6),
ColumnDescriptor(header: "Prizepool", number: true, widthWeight: 1.0),
- ColumnDescriptor(header: "Entries", number: true, widthWeight: 0.6)]
+ ColumnDescriptor(header: "Entries", number: true, widthWeight: 0.4)]
}
func cellValues() -> [String] {