Update for 2022

master
Laurent 3 years ago
parent 23eded127b
commit 9ac9a080b5
  1. 16
      TournamentStats/AppDelegate.swift
  2. 28
      TournamentStats/UI/reports/InfographyView.swift
  3. 202
      TournamentStats/UI/reports/InfographyView.xib
  4. 7
      TournamentStats/core/Formatters.swift
  5. 9
      TournamentStats/realm/Model.swift
  6. 50
      TournamentStats/report/Queries.swift
  7. 6
      TournamentStats/report/ReportGenerator.swift
  8. 41
      TournamentStats/report/structures/CumulatedResults.swift
  9. 17
      TournamentStats/report/structures/TournamentRepresentable.swift
  10. 9
      TournamentStats/report/structures/TournamentWinner.swift
  11. 241
      TournamentStats/scrapper/Downloader.swift
  12. 4
      TournamentStats/utils/Game.swift

@ -17,13 +17,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
@ -43,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
// try! realm.write {
// realm.deleteAll()
// }
//
// Downloader.downloadWSOPResults()
let generator = ReportGenerator()

@ -57,6 +57,9 @@ class InfographyView: UIView {
@IBOutlet weak var mostTableView: TableView!
@IBOutlet weak var mostTableView2: TableView!
@IBOutlet weak var most10kCashTableView: TableView!
@IBOutlet weak var biggest10kWinnersTableView: TableView!
@IBOutlet weak var hStack2a: UIStackView!
@IBOutlet weak var label21: UILabel!
@IBOutlet weak var label22: UILabel!
@ -79,15 +82,12 @@ class InfographyView: UIView {
@IBOutlet weak var hStack4a: UIStackView!
@IBOutlet weak var label41: UILabel!
@IBOutlet weak var label42: UILabel!
@IBOutlet weak var hStack4b: UIStackView!
@IBOutlet weak var container41: UIView!
@IBOutlet weak var container42: UIView!
@IBOutlet weak var hStack5a: UIStackView!
@IBOutlet weak var label51: UILabel!
@IBOutlet weak var labelTableSize: Label!
@IBOutlet weak var hStack5b: UIStackView!
@IBOutlet weak var collectionView51: UICollectionView!
@ -109,7 +109,7 @@ class InfographyView: UIView {
return
}
self.infographyTitle.text = "2021 World Series of Poker"
self.infographyTitle.text = "2022 World Series of Poker"
self.infographyTitle.textColor = Fonts.color
self.infographyTitle.font = Fonts.mainTitle
@ -125,6 +125,12 @@ class InfographyView: UIView {
self.mostTableView2.setHeader(header: "Most final tables")
self.mostTableView2.setData(data: generator.finalTables, maxRows: 10)
self.most10kCashTableView.setHeader(header: "Most cashes for 10k+ buy-ins")
self.most10kCashTableView.setData(data: generator.mostCashesIn10KPlus, maxRows: 5)
self.biggest10kWinnersTableView.setHeader(header: "Biggest winners for 10k+ buy-in")
self.biggest10kWinnersTableView.setData(data: generator.biggest10KPlusWinners, maxRows: 5)
/////
self.tableView11.setData(data: generator.biggestWinners)
@ -158,11 +164,12 @@ class InfographyView: UIView {
self.tableView31.setData(data: generator.tourniesByPrizepool, maxRows: 5)
self.tableView32.setHeader(header: "Events by entries")
self.tableView32.setData(data: generator.tourniesByEntries, maxRows: 5)
self.tableView33.setHeader(header: "10k championship winners")
self.tableView33.setData(data: generator.championshipWinners, maxRows: Int.max)
/////
self.label41.text = "USA vs. World bracelets"
self.label42.text = "Games distribution"
let USABraceletsDistribBarChart = BarChart(frame: barChartFrame)
USABraceletsDistribBarChart.data = generator.USAvsWorldWins.barChartData
@ -173,8 +180,6 @@ class InfographyView: UIView {
let holdemDistributionBarChart = BarChart(frame: barChartFrame)
holdemDistributionBarChart.data = generator.gamesDistribution.barChartData
holdemDistributionBarChart.setXAxisLabels(generator.gamesDistribution.labels)
self.container42.addSubview(holdemDistributionBarChart)
self.container42.addMaxConstraints(view: holdemDistributionBarChart)
self.label51.text = "Average event"
let ds: TournamentStats? = generator.averageEvent.first
@ -182,11 +187,10 @@ class InfographyView: UIView {
self.collectionView51.dataSource = ds
self.collectionView51.delegate = ds
self.labelTableSize.text = "No-Limit Hold'em table sizes"
let tableSizeDistributionBarChart = BarChart(frame: barChartFrame)
tableSizeDistributionBarChart.data = generator.tableSizeDistribution.barChartData
tableSizeDistributionBarChart.setXAxisLabels(generator.tableSizeDistribution.labels)
self.containerTableSize.addSubview(tableSizeDistributionBarChart)
// let tableSizeDistributionBarChart = BarChart(frame: barChartFrame)
// tableSizeDistributionBarChart.data = generator.tableSizeDistribution.barChartData
// tableSizeDistributionBarChart.setXAxisLabels(generator.tableSizeDistribution.labels)
// self.containerTableSize.addSubview(tableSizeDistributionBarChart)
}
}

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@ -12,23 +12,49 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="InfographyView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="1500" height="4200"/>
<rect key="frame" x="0.0" y="0.0" width="1500" height="4400"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="w79-xx-Evx">
<rect key="frame" x="100" y="44" width="1300" height="4036"/>
<rect key="frame" x="100" y="44" width="1300" height="4314"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2019 WSOP" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Hu-Ou-nFd">
<rect key="frame" x="0.0" y="0.0" width="1300" height="100"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Uch-Cx-I48">
<rect key="frame" x="0.0" y="0.0" width="1300" height="128"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2019 WSOP" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Hu-Ou-nFd">
<rect key="frame" x="0.0" y="0.0" width="1300" height="80"/>
<constraints>
<constraint firstAttribute="height" constant="80" id="mMK-PI-eZm"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="80" id="pCn-2i-fQK"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="assembled by team Poker Analytics" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Jzz-Nv-WGn">
<rect key="frame" x="0.0" y="80" width="1043" height="30"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="30" id="7o2-sn-kXc"/>
<constraint firstAttribute="height" constant="30" id="i5V-jC-imt"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="mMK-PI-eZm"/>
<constraint firstItem="Jzz-Nv-WGn" firstAttribute="leading" secondItem="Uch-Cx-I48" secondAttribute="leading" id="Dfd-e1-ZrK"/>
<constraint firstItem="Jzz-Nv-WGn" firstAttribute="top" secondItem="4Hu-Ou-nFd" secondAttribute="bottom" id="Qlb-3l-Wcq"/>
<constraint firstItem="4Hu-Ou-nFd" firstAttribute="top" secondItem="Uch-Cx-I48" secondAttribute="top" id="Vv3-3r-Cjm"/>
<constraint firstAttribute="trailing" secondItem="Jzz-Nv-WGn" secondAttribute="trailing" constant="257" id="byq-fD-DaH"/>
<constraint firstAttribute="trailing" secondItem="4Hu-Ou-nFd" secondAttribute="trailing" id="rwY-ms-as2"/>
<constraint firstAttribute="height" constant="128" id="tFU-fs-xE0"/>
<constraint firstItem="4Hu-Ou-nFd" firstAttribute="leading" secondItem="Uch-Cx-I48" secondAttribute="leading" id="wof-m6-OHR"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Iu6-Mp-G7e" userLabel="Space">
<rect key="frame" x="0.0" y="110" width="1300" height="50"/>
<rect key="frame" x="0.0" y="138" width="1300" height="50"/>
<viewLayoutGuide key="safeArea" id="cgF-JL-ieX"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@ -36,7 +62,7 @@
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="ABP-ce-MDa">
<rect key="frame" x="0.0" y="170" width="1300" height="500"/>
<rect key="frame" x="0.0" y="198" width="1300" height="500"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" contentInsetAdjustmentBehavior="always" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="Vh3-97-zuO">
<rect key="frame" x="0.0" y="0.0" width="540.5" height="500"/>
@ -63,7 +89,7 @@
</constraints>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="39t-LC-qXh" userLabel="Space">
<rect key="frame" x="0.0" y="680" width="1300" height="20"/>
<rect key="frame" x="0.0" y="708" width="1300" height="20"/>
<viewLayoutGuide key="safeArea" id="xzI-Ex-mMX"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@ -71,31 +97,31 @@
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" spacing="50" translatesAutoresizingMaskIntoConstraints="NO" id="l2y-sT-HQT">
<rect key="frame" x="0.0" y="710" width="1300" height="650"/>
<rect key="frame" x="0.0" y="738" width="1300" height="450"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="uYQ-6Z-Rb4" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="670.5" height="650"/>
<rect key="frame" x="0.0" y="0.0" width="670.5" height="450"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</tableView>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="ubP-cm-Sbp" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="720.5" y="0.0" width="579.5" height="650"/>
<rect key="frame" x="720.5" y="0.0" width="579.5" height="450"/>
<color key="backgroundColor" systemColor="groupTableViewBackgroundColor"/>
</tableView>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="650" id="NZj-7i-hbE"/>
<constraint firstAttribute="height" constant="450" id="NZj-7i-hbE"/>
</constraints>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Xrv-gg-4dD" userLabel="Space">
<rect key="frame" x="0.0" y="1370" width="1300" height="10"/>
<viewLayoutGuide key="safeArea" id="x7x-j2-Rbi"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ToT-7O-4X6" userLabel="Space">
<rect key="frame" x="0.0" y="1198" width="1300" height="20"/>
<viewLayoutGuide key="safeArea" id="olQ-l7-0ae"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="10" id="z1Q-lp-yMy"/>
<constraint firstAttribute="height" constant="20" id="ExJ-cR-RP6"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="50" translatesAutoresizingMaskIntoConstraints="NO" id="NbO-FE-SHj">
<rect key="frame" x="0.0" y="1390" width="1300" height="300"/>
<rect key="frame" x="0.0" y="1228" width="1300" height="300"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="M2m-xf-le9" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="625" height="300"/>
@ -111,15 +137,39 @@
</constraints>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gTW-Xs-enM" userLabel="Space">
<rect key="frame" x="0.0" y="1700" width="1300" height="1"/>
<rect key="frame" x="0.0" y="1538" width="1300" height="1"/>
<viewLayoutGuide key="safeArea" id="PMJ-8b-M0C"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="DCa-vu-Hao"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="50" translatesAutoresizingMaskIntoConstraints="NO" id="2ev-oK-aSd">
<rect key="frame" x="0.0" y="1549" width="1300" height="300"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="lXo-QP-0hK" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="625" height="300"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</tableView>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="N3O-kQ-Qwb" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="675" y="0.0" width="625" height="300"/>
<color key="backgroundColor" systemColor="groupTableViewBackgroundColor"/>
</tableView>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="300" id="AUO-aQ-9dg"/>
</constraints>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Xrv-gg-4dD" userLabel="Space">
<rect key="frame" x="0.0" y="1859" width="1300" height="10"/>
<viewLayoutGuide key="safeArea" id="x7x-j2-Rbi"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="10" id="z1Q-lp-yMy"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="100" translatesAutoresizingMaskIntoConstraints="NO" id="4u9-3E-Qwu">
<rect key="frame" x="0.0" y="1711" width="1300" height="500"/>
<rect key="frame" x="0.0" y="1879" width="1300" height="500"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="JPM-0a-tLH">
<rect key="frame" x="0.0" y="0.0" width="600" height="500"/>
@ -163,7 +213,7 @@
</constraints>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zdb-H8-Dy2" userLabel="Space">
<rect key="frame" x="0.0" y="2221" width="1300" height="80"/>
<rect key="frame" x="0.0" y="2389" width="1300" height="80"/>
<viewLayoutGuide key="safeArea" id="DfJ-ph-q9S"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@ -171,7 +221,7 @@
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="ucv-f0-P2r">
<rect key="frame" x="0.0" y="2311" width="1300" height="280"/>
<rect key="frame" x="0.0" y="2479" width="1300" height="280"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="0h6-mp-rHD" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="1300" height="280"/>
@ -183,7 +233,7 @@
</constraints>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fZP-2C-MlN" userLabel="Space">
<rect key="frame" x="0.0" y="2601" width="1300" height="20"/>
<rect key="frame" x="0.0" y="2769" width="1300" height="20"/>
<viewLayoutGuide key="safeArea" id="3AK-Jb-LaH"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@ -191,7 +241,7 @@
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="JSX-zY-CFg">
<rect key="frame" x="0.0" y="2631" width="1300" height="280"/>
<rect key="frame" x="0.0" y="2799" width="1300" height="280"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="h84-Ta-8eQ" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="1300" height="280"/>
@ -202,8 +252,28 @@
<constraint firstAttribute="height" constant="280" id="e22-At-bAV"/>
</constraints>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="L9B-1D-hE6" userLabel="Space">
<rect key="frame" x="0.0" y="3089" width="1300" height="20"/>
<viewLayoutGuide key="safeArea" id="uYq-3B-XtJ"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="2ad-Zc-RGX"/>
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="rY5-rN-8xE">
<rect key="frame" x="0.0" y="3119" width="1300" height="580"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="bzs-Ub-OTZ" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="1300" height="580"/>
<color key="backgroundColor" systemColor="groupTableViewBackgroundColor"/>
</tableView>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="580" id="oLj-Hg-HlQ"/>
</constraints>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tt8-Z5-vVb" userLabel="Space">
<rect key="frame" x="0.0" y="2921" width="1300" height="20"/>
<rect key="frame" x="0.0" y="3709" width="1300" height="20"/>
<viewLayoutGuide key="safeArea" id="HMN-3V-5QB"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@ -211,7 +281,7 @@
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="100" translatesAutoresizingMaskIntoConstraints="NO" id="9WN-7G-oBN">
<rect key="frame" x="0.0" y="2951" width="1300" height="575"/>
<rect key="frame" x="0.0" y="3739" width="1300" height="575"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="AMm-tC-vDZ">
<rect key="frame" x="0.0" y="0.0" width="600" height="575"/>
@ -231,52 +301,8 @@
</view>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="H3c-Ob-qix">
<rect key="frame" x="700" y="0.0" width="600" height="575"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wcd-nU-zRB" customClass="TitleLabel" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="600" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="fLO-iZ-pCc"/>
</constraints>
<fontDescription key="fontDescription" name="Menlo-Regular" family="Menlo" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LJL-hy-odj">
<rect key="frame" x="0.0" y="60" width="600" height="515"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
</subviews>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="575" id="TTR-HJ-gPu"/>
</constraints>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="100" translatesAutoresizingMaskIntoConstraints="NO" id="2iy-YX-agg">
<rect key="frame" x="0.0" y="3536" width="1300" height="500"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="FFe-7b-fWF">
<rect key="frame" x="0.0" y="0.0" width="600" height="500"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="t1" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7xF-BM-RBb" customClass="TitleLabel" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="600" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="aqm-Jp-xxZ"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="X1y-8P-5GO">
<rect key="frame" x="0.0" y="60" width="600" height="440"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="FXu-gm-zJt">
<rect key="frame" x="700" y="0.0" width="600" height="500"/>
<rect key="frame" x="700" y="0.0" width="600" height="575"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mDV-nN-W7V" customClass="TitleLabel" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="600" height="60"/>
@ -288,7 +314,7 @@
<nil key="highlightedColor"/>
</label>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="tVi-Bi-Ese">
<rect key="frame" x="0.0" y="60" width="600" height="440"/>
<rect key="frame" x="0.0" y="60" width="600" height="515"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="G6p-YK-B8A">
<size key="itemSize" width="50" height="50"/>
@ -301,52 +327,37 @@
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="500" id="U4b-yO-LB0"/>
<constraint firstAttribute="height" constant="575" id="TTR-HJ-gPu"/>
</constraints>
</stackView>
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Assembled by Team Poker Analytics" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Jzz-Nv-WGn">
<rect key="frame" x="8" y="4162" width="1478" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="i5V-jC-imt"/>
</constraints>
<fontDescription key="fontDescription" name="Menlo-Regular" family="Menlo" pointSize="15"/>
<color key="textColor" red="0.33794155689287492" green="0.98525673151016235" blue="0.93577719876040433" alpha="0.5" colorSpace="custom" customColorSpace="displayP3"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="w79-xx-Evx" secondAttribute="trailing" constant="100" id="4VD-EL-9RH"/>
<constraint firstItem="Jzz-Nv-WGn" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="8" id="HnQ-Ow-wNx"/>
<constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="Jzz-Nv-WGn" secondAttribute="trailing" constant="14" id="nwD-KF-aWK"/>
<constraint firstItem="w79-xx-Evx" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="100" id="stc-gy-e36"/>
<constraint firstAttribute="bottom" secondItem="Jzz-Nv-WGn" secondAttribute="bottom" constant="8" id="uTQ-dy-IJ0"/>
<constraint firstItem="w79-xx-Evx" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="usO-r7-R25"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="biggest10kWinnersTableView" destination="N3O-kQ-Qwb" id="3D1-b5-JCD"/>
<outlet property="collectionView" destination="Vh3-97-zuO" id="uR2-F8-eWB"/>
<outlet property="collectionView51" destination="tVi-Bi-Ese" id="f6M-Za-9IQ"/>
<outlet property="container21" destination="Zmk-PV-di2" id="mv0-Sg-r5V"/>
<outlet property="container22" destination="iQu-2n-Y3T" id="Yhg-KD-vzU"/>
<outlet property="container41" destination="YMb-PS-dFz" id="siA-pY-GZT"/>
<outlet property="container42" destination="LJL-hy-odj" id="7Bq-4v-uda"/>
<outlet property="containerTableSize" destination="X1y-8P-5GO" id="bFd-fl-9WZ"/>
<outlet property="hStack1b" destination="ABP-ce-MDa" id="44B-nQ-AOq"/>
<outlet property="hStack2b" destination="4u9-3E-Qwu" id="14V-Za-4Iz"/>
<outlet property="hStack3b" destination="ucv-f0-P2r" id="u9R-aG-IpP"/>
<outlet property="hStack4b" destination="9WN-7G-oBN" id="eAg-zC-ojV"/>
<outlet property="hStack5b" destination="2iy-YX-agg" id="iqW-bN-4fc"/>
<outlet property="infographyTitle" destination="4Hu-Ou-nFd" id="0vL-nP-fjY"/>
<outlet property="label21" destination="Hcr-dr-rUz" id="Ggb-ck-2Y7"/>
<outlet property="label22" destination="2yf-Z5-Tpy" id="5yK-A5-sha"/>
<outlet property="label41" destination="aSt-Fm-PHF" id="43C-8N-8Xk"/>
<outlet property="label42" destination="wcd-nU-zRB" id="WAR-I1-Bej"/>
<outlet property="label51" destination="mDV-nN-W7V" id="QlS-da-9bL"/>
<outlet property="labelTableSize" destination="7xF-BM-RBb" id="fCv-dl-xcS"/>
<outlet property="most10kCashTableView" destination="lXo-QP-0hK" id="0ZM-Xw-Tt5"/>
<outlet property="mostTableView" destination="uYQ-6Z-Rb4" id="Jeb-OU-Gj8"/>
<outlet property="mostTableView2" destination="ubP-cm-Sbp" id="a9y-yZ-4EW"/>
<outlet property="tableView11" destination="HbR-TC-HeD" id="P5k-OS-JgN"/>
@ -354,6 +365,7 @@
<outlet property="tableView13" destination="Vdb-nD-4Cy" id="XXM-W3-Hu0"/>
<outlet property="tableView31" destination="0h6-mp-rHD" id="Huj-wS-RGv"/>
<outlet property="tableView32" destination="h84-Ta-8eQ" id="ffQ-bn-NJj"/>
<outlet property="tableView33" destination="bzs-Ub-OTZ" id="TzQ-Lh-VqN"/>
</connections>
<point key="canvasLocation" x="-1700.0000000000002" y="-204.24107142857142"/>
</view>

@ -91,6 +91,13 @@ class Formatter {
return formatter
}
static var longDate: DateFormatter {
let formatter = DateFormatter()
formatter.dateStyle = .full
formatter.timeStyle = .none
return formatter
}
static var fileDate: DateFormatter {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy_MM_dd"

@ -19,6 +19,8 @@ class Festival : Object, Named {
class Tournament : Object, Named {
private let mainEventNumber = 70
@objc dynamic var date: Date = Date()
@objc dynamic var number: Int = 0
@objc dynamic var buyin: Int = 0
@ -31,9 +33,10 @@ class Tournament : Object, Named {
static var defaultColumns: [Columns] = [.rank, .player, .earnings, .poy, .city, .state, .country]
// NOT USED WITH SCRAPPING
var rows: [Columns] {
switch self.number {
case 1, 10, 32, 39, 47, 53, 57, 81, 87: return [.rank, .player, .earnings, .city, .state, .country]
case 1, 47, 59, 61, 81, 87: return [.rank, .player, .earnings, .city, .state, .country]
default: return Tournament.defaultColumns
}
}
@ -43,6 +46,10 @@ class Tournament : Object, Named {
// return "\(self.buyin.currencyFormatted) \(self.name) (#\(self.number))"
}
var isMainEvent: Bool {
return self.number == mainEventNumber
}
}
class Player : Object, Named {

@ -39,6 +39,20 @@ class Queries {
})
}
static func biggestWinnersAt10k(realm: Realm) -> [CumulatedResults] {
let players = realm.objects(Player.self)
var crArray: [CumulatedResults] = []
for player in players {
crArray.append(CumulatedResults(player: player, options: [.moreThan10KNotMainEvent]))
}
return crArray.sorted(by: { (cr1, cr2) -> Bool in
return cr1.total > cr2.total
})
}
static func averageCash(realm: Realm, minCount: Int) -> BestAverageCash {
let players = realm.objects(Player.self).filter(NSPredicate(format: "results.@count >= %i", minCount))
@ -54,7 +68,7 @@ class Queries {
return BestAverageCash(minimumCashes: minCount, results: results)
}
static func mostCashes(realm: Realm, notable: Bool = false) -> [CumulatedResults] {
static func mostCashes(realm: Realm, notable: Bool = false, moreThan10k: Bool = false) -> [CumulatedResults] {
var players = realm.objects(Player.self)
if (notable) {
@ -63,7 +77,13 @@ class Queries {
var crArray: [CumulatedResults] = []
for player in players {
crArray.append(CumulatedResults(player: player, options: [.countSorted]))
var options: [CumulatedResults.Options] = [.countSorted]
if moreThan10k {
options.append(.moreThan10KNotMainEvent)
}
crArray.append(CumulatedResults(player: player, options: options))
}
return crArray.sorted(by: { (cr1, cr2) -> Bool in
@ -90,15 +110,16 @@ class Queries {
})
}
static func allWinnersSortedByEvent(realm: Realm, date: Date? = nil) -> [TournamentWinner] {
static func allWinnersSortedByEvent(realm: Realm, date: Date? = nil, championship: Bool = false) -> [TournamentWinner] {
let winners: Results<Result>
if let day = date {
winners = realm.objects(Result.self).filter("rank == 1 && ANY tournaments.date IN %@", [day])
} else if championship {
winners = realm.objects(Result.self).filter("rank == 1 && ANY tournaments.name CONTAINS 'Championship' && ANY tournaments.buyin == 10000")
} else {
winners = realm.objects(Result.self).filter("rank == 1")
}
// winners = realm.objects(Result.self).filter("rank == 1")
var tws: [TournamentWinner] = []
@ -107,8 +128,14 @@ class Queries {
tws.append(tw)
}
tws.sort { (tw1, tw2) -> Bool in
tw1.tournament.number < tw2.tournament.number
if championship {
tws.sort { (tw1, tw2) -> Bool in
tw1.result.earnings > tw2.result.earnings
}
} else {
tws.sort { (tw1, tw2) -> Bool in
tw1.tournament.number < tw2.tournament.number
}
}
return tws
@ -281,20 +308,17 @@ class Queries {
let tournaments: Results<Tournament> = realm.objects(Tournament.self)
let noLimitHoldem = DistributionCounter(name: Game.holdem.label)
let potLimitOmaha = DistributionCounter(name: Game.omaha.label)
let holdem = DistributionCounter(name: Game.holdem.label)
// let potLimitOmaha = DistributionCounter(name: Game.omaha.label)
let not = DistributionCounter(name: "Others")
let games: [DistributionCounter] = [noLimitHoldem, potLimitOmaha, not]
let games: [DistributionCounter] = [holdem, not]
tournaments.forEach { tournament in
if tournament.name.contains(Game.holdem.rawValue) {
noLimitHoldem.increment()
} else if tournament.name.contains(Game.omaha.rawValue) {
potLimitOmaha.increment()
holdem.increment()
} else {
not.increment()
}
}
return games
}

@ -55,8 +55,10 @@ class ReportGenerator {
var festivalStats: FestivalStats = FestivalStats()
var biggestWinners: [CumulatedResults] = []
var biggest10KPlusWinners: [CumulatedResults] = []
var mostWins: [CumulatedWins] = []
var mostCashes: [CumulatedResults] = []
var mostCashesIn10KPlus: [CumulatedResults] = []
var tournamentWinners: [TournamentWinner] = []
var tourniesByEntries: [TournamentRepresentable] = []
var tourniesByPrizepool: [TournamentRepresentable] = []
@ -73,6 +75,7 @@ class ReportGenerator {
var rankings1: PlayerNotableFinishesDataSource = PlayerNotableFinishesDataSource(notableFinishes: [])
var finalTables: [CumulatedResults] = []
var tableSizeDistribution: [DistributionCounter] = []
var championshipWinners: [TournamentWinner] = []
func generateReports() {
@ -82,9 +85,12 @@ class ReportGenerator {
self.festivalStats = Queries.festivalStats(realm: realm)
self.biggestWinners = Queries.biggestWinners(realm: realm)
self.biggest10KPlusWinners = Queries.biggestWinnersAt10k(realm: realm)
self.mostWins = Queries.mostWins(realm: realm)
self.mostCashes = Queries.mostCashes(realm: realm)
self.mostCashesIn10KPlus = Queries.mostCashes(realm: realm, moreThan10k: true)
self.tournamentWinners = Queries.allWinnersSortedByEvent(realm: realm)
self.championshipWinners = Queries.allWinnersSortedByEvent(realm: realm, championship: true)
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)

@ -21,11 +21,11 @@ class CumulatedResults : HTMLRepresentable, ColumnRepresentable {
case average
case countSorted
case finalTables
case moreThan10KNotMainEvent
}
let player: Player
var options: [Options] = []
// var average: Bool = false
var finalTables: Bool = false
var total: Double = 0.0
@ -46,10 +46,23 @@ class CumulatedResults : HTMLRepresentable, ColumnRepresentable {
init(player: Player, options: [Options] = []) {
self.player = player
self.options = options
// self.average = average
for result in player.results {
self.add(result: result)
guard let tournament = result.tournaments.first else {
continue
}
let tournamentBuyin: Int = tournament.buyin
if self.options.contains(.moreThan10KNotMainEvent) {
if tournamentBuyin >= 10000 && !tournament.isMainEvent {
self.add(result: result)
}
} else {
self.add(result: result)
}
}
if self.options.contains(.average) {
self.total = self.total / Double(self.numberOfCashes)
@ -57,7 +70,7 @@ class CumulatedResults : HTMLRepresentable, ColumnRepresentable {
}
private func add(result: Result) {
if result.tournaments.first?.number == 67 && result.rank < 10 {
if result.tournaments.first?.isMainEvent == true && result.rank < 10 {
self.mainEventFinalist = true
}
@ -99,24 +112,4 @@ class CumulatedResults : HTMLRepresentable, ColumnRepresentable {
}
}
// func htmlHeaders() -> String {
// var strings: [String] = []
// strings.append("Name")
//// strings.append("Places (Year)")
// strings.append("Total Earnings")
// strings.append("Cashes")
// let all = strings.joined(separator: "</td><td>")
// return "<tr class=\"table-header\"><td>\(all)</td></tr>"
// }
//
// func html() -> String {
// var strings: [String] = []
// strings.append(self.player.formattedName)
//// strings.append(self.results.map { "\($0.rank.rankFormatted) (\($0.tournaments.first?.date.year ?? ""))" }.joined(separator: ", "))
// strings.append(self.total.currencyFormatted)
// strings.append("\(self.numberOfCashes)")
// let all = strings.joined(separator: "</td><td>")
// return "<tr><td>\(all)</td></tr>"
// }
}

@ -13,7 +13,7 @@ struct TournamentRepresentable : HTMLRepresentable {
var tournament: Tournament
func columnDescriptors() -> [ColumnDescriptor] {
return [ColumnDescriptor(header: "#", number: true, widthWeight: 0.2),
return [
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),
@ -22,7 +22,6 @@ struct TournamentRepresentable : HTMLRepresentable {
func cellValues() -> [String] {
return [
"\(tournament.number)",
tournament.buyin.currencyFormatted,
tournament.name,
tournament.prizepool.currencyFormatted,
@ -32,8 +31,6 @@ struct TournamentRepresentable : HTMLRepresentable {
func htmlHeaders() -> String {
var strings: [String] = []
// strings.append("Date")
strings.append("#")
strings.append("Buy-in")
strings.append("Event")
strings.append("Prizepool")
@ -42,16 +39,4 @@ struct TournamentRepresentable : HTMLRepresentable {
return "<tr class=\"table-header\"><td width=\"50\">\(all)</td></tr>"
}
// func html() -> String {
// var strings: [String] = []
//// strings.append(tournament.date.year)
// strings.append("\(tournament.number)")
// strings.append(tournament.buyin.currencyFormatted)
// strings.append(tournament.name)
// strings.append(tournament.prizepool.currencyFormatted)
// strings.append("\(tournament.entries)")
// let all = strings.joined(separator: "</td><td>")
// return "<tr><td>\(all)</td></tr>"
// }
}

@ -14,15 +14,15 @@ struct TournamentWinner : HTMLRepresentable {
var result: Result
func columnDescriptors() -> [ColumnDescriptor] {
return [ColumnDescriptor(header: "#", number: true, widthWeight: 0.2),
ColumnDescriptor(header: "Buy-in", number: true, widthWeight: 1.0),
ColumnDescriptor(header: "Event", number: false, widthWeight: 1.0),
return [
ColumnDescriptor(header: "Buy-in", number: true, widthWeight: 0.5),
ColumnDescriptor(header: "Event", number: false, widthWeight: 3.0),
ColumnDescriptor(header: "Player", number: false, widthWeight: 1.0),
ColumnDescriptor(header: "Prize", number: true, widthWeight: 1.0)]
}
func cellValues() -> [String] {
return ["\(tournament.number)",
return [
tournament.buyin.currencyFormatted,
tournament.name,
result.player?.formattedName ?? "",
@ -32,7 +32,6 @@ struct TournamentWinner : HTMLRepresentable {
func htmlHeaders() -> String {
var header = ""
header.append("<td width=\"50\">#</td>")
header.append("<td width=\"100\">Buy-in</td>")
header.append("<td>Event</td>")
header.append("<td>Player</td>")

@ -18,111 +18,115 @@ class Downloader {
static func downloadWSOPResults() {
let infos: [TS] = [
TS(id: "19728", date: "02/10/2021"),
TS(id: "19729", date: "03/10/2021"),
TS(id: "19730", date: "02/10/2021"),
TS(id: "19732", date: "04/10/2021"),
TS(id: "19733", date: "05/10/2021"),
TS(id: "19731", date: "06/10/2021"),
TS(id: "19734", date: "06/10/2021"),
TS(id: "19926", date: "06/10/2021"),
TS(id: "19927", date: "06/10/2021"),
TS(id: "19737", date: "06/10/2021"),
TS(id: "19735", date: "07/10/2021"),
TS(id: "19736", date: "08/10/2021"),
TS(id: "19738", date: "08/10/2021"),
TS(id: "19739", date: "08/10/2021"),
TS(id: "19740", date: "09/10/2021"),
TS(id: "19741", date: "09/10/2021"),
TS(id: "19928", date: "10/10/2021"),
TS(id: "19742", date: "11/10/2021"),
TS(id: "19743", date: "11/10/2021"),
TS(id: "19745", date: "12/10/2021"),
TS(id: "19747", date: "12/10/2021"),
TS(id: "19748", date: "12/10/2021"),
TS(id: "19749", date: "13/10/2021"),
TS(id: "19744", date: "14/10/2021"),
TS(id: "19751", date: "14/10/2021"),
TS(id: "19752", date: "14/10/2021"),
TS(id: "19750", date: "15/10/2021"),
TS(id: "19754", date: "15/10/2021"),
TS(id: "19753", date: "16/10/2021"),
TS(id: "19755", date: "16/10/2021"),
TS(id: "19756", date: "17/10/2021"),
TS(id: "19757", date: "17/10/2021"),
TS(id: "19759", date: "17/10/2021"),
TS(id: "19929", date: "17/10/2021"),
TS(id: "19761", date: "19/10/2021"),
TS(id: "19762", date: "19/10/2021"),
TS(id: "19758", date: "20/10/2021"),
TS(id: "19763", date: "20/10/2021"),
TS(id: "19764", date: "20/10/2021"),
TS(id: "19765", date: "21/10/2021"),
TS(id: "19766", date: "21/10/2021"),
TS(id: "19767", date: "22/10/2021"),
TS(id: "19768", date: "23/10/2021"),
TS(id: "19769", date: "24/10/2021"),
TS(id: "19770", date: "24/10/2021"),
TS(id: "19771", date: "24/10/2021"),
TS(id: "19930", date: "24/10/2021"),
TS(id: "19832", date: "25/10/2021"),
TS(id: "19774", date: "26/10/2021"),
TS(id: "19772", date: "27/10/2021"),
TS(id: "19773", date: "27/10/2021"),
TS(id: "19775", date: "27/10/2021"),
TS(id: "19776", date: "28/10/2021"),
TS(id: "19778", date: "28/10/2021"),
TS(id: "19779", date: "28/10/2021"),
TS(id: "19780", date: "28/10/2021"),
TS(id: "19782", date: "31/10/2021"),
TS(id: "19784", date: "31/10/2021"),
TS(id: "19931", date: "31/10/2021"),
TS(id: "19781", date: "01/11/2021"),
TS(id: "19786", date: "01/11/2021"),
TS(id: "19785", date: "02/11/2021"),
TS(id: "19788", date: "02/11/2021"),
TS(id: "19789", date: "03/11/2021"),
TS(id: "19790", date: "03/11/2021"),
TS(id: "19792", date: "04/11/2021"),
TS(id: "19793", date: "04/11/2021"),
TS(id: "19795", date: "04/11/2021"),
TS(id: "19794", date: "05/11/2021"),
TS(id: "19791", date: "06/11/2021"),
TS(id: "19796", date: "06/11/2021"),
TS(id: "19797", date: "06/11/2021"),
TS(id: "19805", date: "13/11/2021"),
TS(id: "19802", date: "14/11/2021"),
TS(id: "19807", date: "14/11/2021"),
TS(id: "19809", date: "15/11/2021"),
TS(id: "19811", date: "15/11/2021"),
TS(id: "19933", date: "16/11/2021"),
TS(id: "19934", date: "16/11/2021"),
TS(id: "19808", date: "17/11/2021"),
TS(id: "19813", date: "17/11/2021"),
TS(id: "19815", date: "17/11/2021"),
TS(id: "19798", date: "18/11/2021"),
TS(id: "19814", date: "18/11/2021"),
TS(id: "19816", date: "18/11/2021"),
TS(id: "19817", date: "20/11/2021"),
TS(id: "19818", date: "20/11/2021"),
TS(id: "19819", date: "20/11/2021"),
TS(id: "19820", date: "20/11/2021"),
TS(id: "19821", date: "21/11/2021"),
TS(id: "19822", date: "21/11/2021"),
TS(id: "19823", date: "21/11/2021"),
TS(id: "19827", date: "21/11/2021"),
TS(id: "19828", date: "22/11/2021"),
TS(id: "19829", date: "22/11/2021"),
TS(id: "19936", date: "22/11/2021"),
TS(id: "19935", date: "22/11/2021"),
TS(id: "19830", date: "22/11/2021"),
]
for info in infos {
let ids = ["20342", "20387", "20301", "20607", "20327", "20599", "20305", "20358", "20320", "20313", "20339", "20598", "20329", "20383", "20350", "20328", "20334", "20368", "20375", "20374", "20325", "20370", "20343", "20344", "20600", "20323", "20309", "20379", "20384", "20337", "20373", "20605", "20318", "20601", "20340", "20330", "20314", "20352", "20603", "20304", "20324", "20386", "20315", "20341", "20322", "20604", "20354", "20382", "20363", "20377", "20359", "20366", "20331", "20336", "20376", "20606", "20345", "20346", "20385", "20311", "20312", "20303", "20308", "20326", "20378", "20356", "20602", "20371", "20369", "20357", "20361", "20608", "20319", "20347", "20306", "20310", "20609", "20367", "20351", "20349", "20321", "20348", "20355", "20333", "20360", "20389", "20372", "20338", "20353", "20364", "20317", "20335", "20307", "20332", "20610", "20316", "20381", "20388", "20302", "20380", "20362", "20365"]
// let infos: [TS] = [
// TS(id: "19728", date: "02/10/2021"),
// TS(id: "19729", date: "03/10/2021"),
// TS(id: "19730", date: "02/10/2021"),
// TS(id: "19732", date: "04/10/2021"),
// TS(id: "19733", date: "05/10/2021"),
// TS(id: "19731", date: "06/10/2021"),
// TS(id: "19734", date: "06/10/2021"),
// TS(id: "19926", date: "06/10/2021"),
// TS(id: "19927", date: "06/10/2021"),
// TS(id: "19737", date: "06/10/2021"),
// TS(id: "19735", date: "07/10/2021"),
// TS(id: "19736", date: "08/10/2021"),
// TS(id: "19738", date: "08/10/2021"),
// TS(id: "19739", date: "08/10/2021"),
// TS(id: "19740", date: "09/10/2021"),
// TS(id: "19741", date: "09/10/2021"),
// TS(id: "19928", date: "10/10/2021"),
// TS(id: "19742", date: "11/10/2021"),
// TS(id: "19743", date: "11/10/2021"),
// TS(id: "19745", date: "12/10/2021"),
// TS(id: "19747", date: "12/10/2021"),
// TS(id: "19748", date: "12/10/2021"),
// TS(id: "19749", date: "13/10/2021"),
// TS(id: "19744", date: "14/10/2021"),
// TS(id: "19751", date: "14/10/2021"),
// TS(id: "19752", date: "14/10/2021"),
// TS(id: "19750", date: "15/10/2021"),
// TS(id: "19754", date: "15/10/2021"),
// TS(id: "19753", date: "16/10/2021"),
// TS(id: "19755", date: "16/10/2021"),
// TS(id: "19756", date: "17/10/2021"),
// TS(id: "19757", date: "17/10/2021"),
// TS(id: "19759", date: "17/10/2021"),
// TS(id: "19929", date: "17/10/2021"),
// TS(id: "19761", date: "19/10/2021"),
// TS(id: "19762", date: "19/10/2021"),
// TS(id: "19758", date: "20/10/2021"),
// TS(id: "19763", date: "20/10/2021"),
// TS(id: "19764", date: "20/10/2021"),
// TS(id: "19765", date: "21/10/2021"),
// TS(id: "19766", date: "21/10/2021"),
// TS(id: "19767", date: "22/10/2021"),
// TS(id: "19768", date: "23/10/2021"),
// TS(id: "19769", date: "24/10/2021"),
// TS(id: "19770", date: "24/10/2021"),
// TS(id: "19771", date: "24/10/2021"),
// TS(id: "19930", date: "24/10/2021"),
// TS(id: "19832", date: "25/10/2021"),
// TS(id: "19774", date: "26/10/2021"),
// TS(id: "19772", date: "27/10/2021"),
// TS(id: "19773", date: "27/10/2021"),
// TS(id: "19775", date: "27/10/2021"),
// TS(id: "19776", date: "28/10/2021"),
// TS(id: "19778", date: "28/10/2021"),
// TS(id: "19779", date: "28/10/2021"),
// TS(id: "19780", date: "28/10/2021"),
// TS(id: "19782", date: "31/10/2021"),
// TS(id: "19784", date: "31/10/2021"),
// TS(id: "19931", date: "31/10/2021"),
// TS(id: "19781", date: "01/11/2021"),
// TS(id: "19786", date: "01/11/2021"),
// TS(id: "19785", date: "02/11/2021"),
// TS(id: "19788", date: "02/11/2021"),
// TS(id: "19789", date: "03/11/2021"),
// TS(id: "19790", date: "03/11/2021"),
// TS(id: "19792", date: "04/11/2021"),
// TS(id: "19793", date: "04/11/2021"),
// TS(id: "19795", date: "04/11/2021"),
// TS(id: "19794", date: "05/11/2021"),
// TS(id: "19791", date: "06/11/2021"),
// TS(id: "19796", date: "06/11/2021"),
// TS(id: "19797", date: "06/11/2021"),
// TS(id: "19805", date: "13/11/2021"),
// TS(id: "19802", date: "14/11/2021"),
// TS(id: "19807", date: "14/11/2021"),
// TS(id: "19809", date: "15/11/2021"),
// TS(id: "19811", date: "15/11/2021"),
// TS(id: "19933", date: "16/11/2021"),
// TS(id: "19934", date: "16/11/2021"),
// TS(id: "19808", date: "17/11/2021"),
// TS(id: "19813", date: "17/11/2021"),
// TS(id: "19815", date: "17/11/2021"),
// TS(id: "19798", date: "18/11/2021"),
// TS(id: "19814", date: "18/11/2021"),
// TS(id: "19816", date: "18/11/2021"),
// TS(id: "19817", date: "20/11/2021"),
// TS(id: "19818", date: "20/11/2021"),
// TS(id: "19819", date: "20/11/2021"),
// TS(id: "19820", date: "20/11/2021"),
// TS(id: "19821", date: "21/11/2021"),
// TS(id: "19822", date: "21/11/2021"),
// TS(id: "19823", date: "21/11/2021"),
// TS(id: "19827", date: "21/11/2021"),
// TS(id: "19828", date: "22/11/2021"),
// TS(id: "19829", date: "22/11/2021"),
// TS(id: "19936", date: "22/11/2021"),
// TS(id: "19935", date: "22/11/2021"),
// TS(id: "19830", date: "22/11/2021"),
//
// ]
for id in ids {
sleep(1)
downloadWSOPResults(tournamentInfo: info)
downloadWSOPResults(id: id)
}
// for i in 19728...19732 {
@ -135,17 +139,16 @@ class Downloader {
}
fileprivate static func downloadWSOPResults(tournamentInfo: TS) {
fileprivate static func downloadWSOPResults(id: String) {
print("Importing tournament \(tournamentInfo.id)")
guard let url = URL(string: "https://www.wsop.com/tournaments/results/?aid=2&grid=4865&tid=\(tournamentInfo.id)&rr=5") else {
print("Importing tournament \(id)")
guard let url = URL(string: "https://www.wsop.com/tournaments/results/?aid=2&grid=4943&tid=\(id)&rr=5") else {
return
}
let realm = try! Realm()
do {
try realm.write {
self.downloadWSOPResults(url: url, date: tournamentInfo.date)
self.downloadWSOPResults(url: url)
}
} catch {
print("error = \(error)")
@ -153,7 +156,7 @@ class Downloader {
}
fileprivate static func downloadWSOPResults(url: URL, date: String, currentTournament: Tournament? = nil) {
fileprivate static func downloadWSOPResults(url: URL, currentTournament: Tournament? = nil) {
let realm = try! Realm()
@ -177,9 +180,19 @@ class Downloader {
let tour = realm.create(Tournament.self)
tournament = tour
// <p>Sunday, July 17, 2022 to Sunday, July 17, 2022</p>
if let name = infos.slice(from: "<h1>", to: "</h1>") {
tour.name = name
tour.date = Formatter.basicDate.date(from: date) ?? Date()
let fullDatesString = infos.slice(from: "<p>", to: "</p>")
let fullDates = fullDatesString?.components(separatedBy: " to ")
if let endString = fullDates?.last, let end = Formatter.longDate.date(from: endString) {
tour.date = end
} else {
print("Using now for date")
tour.date = Date()
}
if let strNumber = name.slice(from: "Event #", to: ":"), let number = nf.number(from: strNumber) {
tour.number = number.intValue
@ -188,9 +201,11 @@ class Downloader {
if name.contains("6-Handed") {
tour.tableSize = 6
} else if name.contains("7-Handed") {
tour.tableSize = 7
} else if name.contains("8-Handed") {
tour.tableSize = 8
} else if name.contains("Heads-Up") {
} else if name.contains("Heads-Up") || name.contains("Heads Up") {
tour.tableSize = 2
}
@ -302,7 +317,7 @@ class Downloader {
let components = pages[i].components(separatedBy: "'")
if let urlString = components.first,
let url = URL(string: "https://www.wsop.com\(urlString)") {
self.downloadWSOPResults(url: url, date: date, currentTournament: tournament)
self.downloadWSOPResults(url: url, currentTournament: tournament)
}
}
}

@ -9,12 +9,12 @@
import Foundation
enum Game : String {
case holdem = "No-Limit Hold'em"
case holdem = "Hold'em"
case omaha = "Pot-Limit Omaha"
var label: String {
switch self {
case .holdem: return "NL Hold'em"
case .holdem: return "Hold'em"
case .omaha: return "PL Omaha"
}
}

Loading…
Cancel
Save