Added festival stats

master
Laurent 6 years ago
parent 3bf0aa4eb4
commit 6e89912d22
  1. 22
      TournamentStats.xcodeproj/project.pbxproj
  2. 12
      TournamentStats/UI/reports/InfographyView.swift
  3. 38
      TournamentStats/UI/reports/InfographyView.xib
  4. 17
      TournamentStats/UI/reports/StatCollectionViewCell.swift
  5. 57
      TournamentStats/UI/reports/StatCollectionViewCell.xib
  6. 15
      TournamentStats/core/Formatters.swift
  7. 13
      TournamentStats/report/Queries.swift
  8. 2
      TournamentStats/report/ReportGenerator.swift
  9. 10
      TournamentStats/report/structures/CumulatedResults.swift
  10. 64
      TournamentStats/report/structures/FestivalStats.swift

@ -11,6 +11,9 @@
4D0F103722C4C08F005F797A /* ChipCount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D0F103622C4C08F005F797A /* ChipCount.swift */; }; 4D0F103722C4C08F005F797A /* ChipCount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D0F103622C4C08F005F797A /* ChipCount.swift */; };
4D0F103922C4C1C4005F797A /* ChipCountParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D0F103822C4C1C4005F797A /* ChipCountParser.swift */; }; 4D0F103922C4C1C4005F797A /* ChipCountParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D0F103822C4C1C4005F797A /* ChipCountParser.swift */; };
4D18861122C36D8F0020C4CD /* TournamentCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D18861022C36D8F0020C4CD /* TournamentCounter.swift */; }; 4D18861122C36D8F0020C4CD /* TournamentCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D18861022C36D8F0020C4CD /* TournamentCounter.swift */; };
4D26A94D23152316001C98D2 /* FestivalStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D26A94C23152316001C98D2 /* FestivalStats.swift */; };
4D26A94F23152A1C001C98D2 /* StatCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4D26A94E23152A1C001C98D2 /* StatCollectionViewCell.xib */; };
4D26A95123152A6B001C98D2 /* StatCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D26A95023152A6B001C98D2 /* StatCollectionViewCell.swift */; };
4D2F1C4422CC92D1007C639E /* event81 in Resources */ = {isa = PBXBuildFile; fileRef = 4D2F1C2C22CC92CE007C639E /* event81 */; }; 4D2F1C4422CC92D1007C639E /* event81 in Resources */ = {isa = PBXBuildFile; fileRef = 4D2F1C2C22CC92CE007C639E /* event81 */; };
4D2F1C4522CC92D1007C639E /* event80 in Resources */ = {isa = PBXBuildFile; fileRef = 4D2F1C2D22CC92CE007C639E /* event80 */; }; 4D2F1C4522CC92D1007C639E /* event80 in Resources */ = {isa = PBXBuildFile; fileRef = 4D2F1C2D22CC92CE007C639E /* event80 */; };
4D2F1C4622CC92D1007C639E /* event76 in Resources */ = {isa = PBXBuildFile; fileRef = 4D2F1C2E22CC92CE007C639E /* event76 */; }; 4D2F1C4622CC92D1007C639E /* event76 in Resources */ = {isa = PBXBuildFile; fileRef = 4D2F1C2E22CC92CE007C639E /* event76 */; };
@ -157,6 +160,9 @@
4D0F103622C4C08F005F797A /* ChipCount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipCount.swift; sourceTree = "<group>"; }; 4D0F103622C4C08F005F797A /* ChipCount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipCount.swift; sourceTree = "<group>"; };
4D0F103822C4C1C4005F797A /* ChipCountParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipCountParser.swift; sourceTree = "<group>"; }; 4D0F103822C4C1C4005F797A /* ChipCountParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipCountParser.swift; sourceTree = "<group>"; };
4D18861022C36D8F0020C4CD /* TournamentCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentCounter.swift; sourceTree = "<group>"; }; 4D18861022C36D8F0020C4CD /* TournamentCounter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentCounter.swift; sourceTree = "<group>"; };
4D26A94C23152316001C98D2 /* FestivalStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FestivalStats.swift; sourceTree = "<group>"; };
4D26A94E23152A1C001C98D2 /* StatCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = StatCollectionViewCell.xib; sourceTree = "<group>"; };
4D26A95023152A6B001C98D2 /* StatCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatCollectionViewCell.swift; sourceTree = "<group>"; };
4D2F1C2C22CC92CE007C639E /* event81 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = event81; sourceTree = "<group>"; }; 4D2F1C2C22CC92CE007C639E /* event81 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = event81; sourceTree = "<group>"; };
4D2F1C2D22CC92CE007C639E /* event80 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = event80; sourceTree = "<group>"; }; 4D2F1C2D22CC92CE007C639E /* event80 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = event80; sourceTree = "<group>"; };
4D2F1C2E22CC92CE007C639E /* event76 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = event76; sourceTree = "<group>"; }; 4D2F1C2E22CC92CE007C639E /* event76 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = event76; sourceTree = "<group>"; };
@ -319,6 +325,8 @@
4D39B6F022F829A500625E31 /* InfographyViewController.swift */, 4D39B6F022F829A500625E31 /* InfographyViewController.swift */,
4DB113D62305480600D0C671 /* InfographyView.xib */, 4DB113D62305480600D0C671 /* InfographyView.xib */,
4DB113D823054A4100D0C671 /* InfographyView.swift */, 4DB113D823054A4100D0C671 /* InfographyView.swift */,
4D26A95023152A6B001C98D2 /* StatCollectionViewCell.swift */,
4D26A94E23152A1C001C98D2 /* StatCollectionViewCell.xib */,
); );
path = reports; path = reports;
sourceTree = "<group>"; sourceTree = "<group>";
@ -535,15 +543,16 @@
4DF7614B22A6677A004B0EF1 /* structures */ = { 4DF7614B22A6677A004B0EF1 /* structures */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
4D39B6FB22F8686300625E31 /* CumulatedWins.swift */, 4D0F103622C4C08F005F797A /* ChipCount.swift */,
4DA5CA1D22AD078A00AC628E /* CountryCounter.swift */,
4DF7614522A59407004B0EF1 /* CumulatedResults.swift */, 4DF7614522A59407004B0EF1 /* CumulatedResults.swift */,
4DF7614922A66675004B0EF1 /* TournamentWinner.swift */, 4D39B6FB22F8686300625E31 /* CumulatedWins.swift */,
4D26A94C23152316001C98D2 /* FestivalStats.swift */,
4DF7614E22A6CF93004B0EF1 /* PlayerResult.swift */, 4DF7614E22A6CF93004B0EF1 /* PlayerResult.swift */,
4D18861022C36D8F0020C4CD /* TournamentCounter.swift */,
4DF7615022A7AECA004B0EF1 /* TournamentRepresentable.swift */, 4DF7615022A7AECA004B0EF1 /* TournamentRepresentable.swift */,
4DA5CA1D22AD078A00AC628E /* CountryCounter.swift */,
4DDEF11322AE4FB900F4D7C1 /* TournamentStats.swift */, 4DDEF11322AE4FB900F4D7C1 /* TournamentStats.swift */,
4D18861022C36D8F0020C4CD /* TournamentCounter.swift */, 4DF7614922A66675004B0EF1 /* TournamentWinner.swift */,
4D0F103622C4C08F005F797A /* ChipCount.swift */,
); );
path = structures; path = structures;
sourceTree = "<group>"; sourceTree = "<group>";
@ -720,6 +729,7 @@
4DF7613A22A56797004B0EF1 /* event17 in Resources */, 4DF7613A22A56797004B0EF1 /* event17 in Resources */,
4DF7612022A56797004B0EF1 /* event31 in Resources */, 4DF7612022A56797004B0EF1 /* event31 in Resources */,
4DF7614122A56797004B0EF1 /* event52 in Resources */, 4DF7614122A56797004B0EF1 /* event52 in Resources */,
4D26A94F23152A1C001C98D2 /* StatCollectionViewCell.xib in Resources */,
4D2F1C4F22CC92D1007C639E /* event79 in Resources */, 4D2F1C4F22CC92D1007C639E /* event79 in Resources */,
4DF7613D22A56797004B0EF1 /* event56 in Resources */, 4DF7613D22A56797004B0EF1 /* event56 in Resources */,
4DF7612422A56797004B0EF1 /* event43 in Resources */, 4DF7612422A56797004B0EF1 /* event43 in Resources */,
@ -779,6 +789,7 @@
files = ( files = (
4DF7614822A59660004B0EF1 /* ReportGenerator.swift in Sources */, 4DF7614822A59660004B0EF1 /* ReportGenerator.swift in Sources */,
4DB113D923054A4100D0C671 /* InfographyView.swift in Sources */, 4DB113D923054A4100D0C671 /* InfographyView.swift in Sources */,
4D26A95123152A6B001C98D2 /* StatCollectionViewCell.swift in Sources */,
4DF78DD422F9C85C00C02F73 /* UIColor+Extensions.swift in Sources */, 4DF78DD422F9C85C00C02F73 /* UIColor+Extensions.swift in Sources */,
4DF760C222A561FF004B0EF1 /* ColumnRepresentable.swift in Sources */, 4DF760C222A561FF004B0EF1 /* ColumnRepresentable.swift in Sources */,
4DF760B022A47C74004B0EF1 /* RowImporter.swift in Sources */, 4DF760B022A47C74004B0EF1 /* RowImporter.swift in Sources */,
@ -788,6 +799,7 @@
4DF760B322A47CAE004B0EF1 /* Realm+Extensions.swift in Sources */, 4DF760B322A47CAE004B0EF1 /* Realm+Extensions.swift in Sources */,
4DF7608822A3FB96004B0EF1 /* DetailViewController.swift in Sources */, 4DF7608822A3FB96004B0EF1 /* DetailViewController.swift in Sources */,
4DF78DD122F9AADF00C02F73 /* TableView.swift in Sources */, 4DF78DD122F9AADF00C02F73 /* TableView.swift in Sources */,
4D26A94D23152316001C98D2 /* FestivalStats.swift in Sources */,
4DF78DD622F9CE7E00C02F73 /* TitleLabel.swift in Sources */, 4DF78DD622F9CE7E00C02F73 /* TitleLabel.swift in Sources */,
4DF7615122A7AECA004B0EF1 /* TournamentRepresentable.swift in Sources */, 4DF7615122A7AECA004B0EF1 /* TournamentRepresentable.swift in Sources */,
4DF7608622A3FB96004B0EF1 /* MasterViewController.swift in Sources */, 4DF7608622A3FB96004B0EF1 /* MasterViewController.swift in Sources */,

@ -19,6 +19,8 @@ class InfographyView: UIView {
@IBOutlet weak var infographyTitle: UILabel! @IBOutlet weak var infographyTitle: UILabel!
@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet weak var hStack1a: UIStackView! @IBOutlet weak var hStack1a: UIStackView!
@IBOutlet weak var label11: UILabel! @IBOutlet weak var label11: UILabel!
@IBOutlet weak var label12: UILabel! @IBOutlet weak var label12: UILabel!
@ -97,6 +99,10 @@ class InfographyView: UIView {
self.infographyTitle.textColor = UIColor.white self.infographyTitle.textColor = UIColor.white
self.infographyTitle.font = Fonts.mainTitle self.infographyTitle.font = Fonts.mainTitle
self.collectionView.register(UINib(nibName: "StatCollectionViewCell", bundle: Bundle.main), forCellWithReuseIdentifier: "Stat")
self.collectionView.delegate = generator.festivalStats
self.collectionView.dataSource = generator.festivalStats
///// /////
self.label11.text = "Biggest Winners".uppercased() self.label11.text = "Biggest Winners".uppercased()
@ -131,13 +137,13 @@ class InfographyView: UIView {
self.label31.text = "Events by prizepool".uppercased() self.label31.text = "Events by prizepool".uppercased()
self.label32.text = "Events by entries".uppercased() self.label32.text = "Events by entries".uppercased()
self.tableView31.setData(data: generator.tourniesByPrizepool) self.tableView31.setData(data: generator.tourniesByPrizepool, maxRows: 5)
self.tableView32.setData(data: generator.tourniesByEntries) self.tableView32.setData(data: generator.tourniesByEntries, maxRows: 5)
///// /////
self.label41.text = "USA vs World bracelets".uppercased() self.label41.text = "USA vs World bracelets".uppercased()
self.label42.text = "Holdem vs exotic games".uppercased() self.label42.text = "Hold'em vs not hold'em".uppercased()
let USABraceletsDistribPie = PieChart(frame: pieChartFrame) let USABraceletsDistribPie = PieChart(frame: pieChartFrame)
USABraceletsDistribPie.data = generator.USAvsWorldWins.pieChartData USABraceletsDistribPie.data = generator.USAvsWorldWins.pieChartData

@ -17,7 +17,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="w79-xx-Evx"> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="w79-xx-Evx">
<rect key="frame" x="8" y="44" width="1784" height="2630"/> <rect key="frame" x="8" y="44" width="1784" height="2740"/>
<subviews> <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"> <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="1784" height="100"/> <rect key="frame" x="0.0" y="0.0" width="1784" height="100"/>
@ -28,8 +28,21 @@
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="C35-qI-rKP">
<rect key="frame" x="0.0" y="110" width="1784" height="100"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="Beg-JJ-WDa"/>
</constraints>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="93i-Pd-4WS">
<size key="itemSize" width="50" height="50"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
</collectionView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="aDf-a7-TD5"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="aDf-a7-TD5">
<rect key="frame" x="0.0" y="110" width="1784" height="50"/> <rect key="frame" x="0.0" y="220" width="1784" height="50"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hf2-oh-1Oz" customClass="Label" customModule="TournamentStats" customModuleProvider="target"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hf2-oh-1Oz" customClass="Label" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="594.5" height="50"/> <rect key="frame" x="0.0" y="0.0" width="594.5" height="50"/>
@ -55,7 +68,7 @@
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="ABP-ce-MDa"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="ABP-ce-MDa">
<rect key="frame" x="0.0" y="170" width="1784" height="400"/> <rect key="frame" x="0.0" y="280" width="1784" height="400"/>
<subviews> <subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="HbR-TC-HeD" customClass="TableView" customModule="TournamentStats" customModuleProvider="target"> <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="HbR-TC-HeD" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="584" height="400"/> <rect key="frame" x="0.0" y="0.0" width="584" height="400"/>
@ -75,7 +88,7 @@
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="91U-hc-Oqn"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="91U-hc-Oqn">
<rect key="frame" x="0.0" y="580" width="1784" height="40"/> <rect key="frame" x="0.0" y="690" width="1784" height="40"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hcr-dr-rUz" customClass="Label" customModule="TournamentStats" customModuleProvider="target"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hcr-dr-rUz" customClass="Label" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="594.5" height="40"/> <rect key="frame" x="0.0" y="0.0" width="594.5" height="40"/>
@ -101,7 +114,7 @@
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="4u9-3E-Qwu"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="4u9-3E-Qwu">
<rect key="frame" x="0.0" y="630" width="1784" height="500"/> <rect key="frame" x="0.0" y="740" width="1784" height="500"/>
<subviews> <subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zmk-PV-di2"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zmk-PV-di2">
<rect key="frame" x="0.0" y="0.0" width="584" height="500"/> <rect key="frame" x="0.0" y="0.0" width="584" height="500"/>
@ -121,7 +134,7 @@
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="RgJ-XU-xav"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="RgJ-XU-xav">
<rect key="frame" x="0.0" y="1140" width="1784" height="50"/> <rect key="frame" x="0.0" y="1250" width="1784" height="50"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zHz-52-q8s" customClass="Label" customModule="TournamentStats" customModuleProvider="target"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zHz-52-q8s" customClass="Label" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="892" height="50"/> <rect key="frame" x="0.0" y="0.0" width="892" height="50"/>
@ -141,7 +154,7 @@
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="ucv-f0-P2r"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="ucv-f0-P2r">
<rect key="frame" x="0.0" y="1200" width="1784" height="400"/> <rect key="frame" x="0.0" y="1310" width="1784" height="400"/>
<subviews> <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"> <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="884" height="400"/> <rect key="frame" x="0.0" y="0.0" width="884" height="400"/>
@ -157,7 +170,7 @@
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="WFa-d3-zcU"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="WFa-d3-zcU">
<rect key="frame" x="0.0" y="1610" width="1784" height="40"/> <rect key="frame" x="0.0" y="1720" width="1784" height="40"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aSt-Fm-PHF" customClass="Label" customModule="TournamentStats" customModuleProvider="target"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aSt-Fm-PHF" customClass="Label" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="892" height="40"/> <rect key="frame" x="0.0" y="0.0" width="892" height="40"/>
@ -177,7 +190,7 @@
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="9WN-7G-oBN"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="9WN-7G-oBN">
<rect key="frame" x="0.0" y="1660" width="1784" height="500"/> <rect key="frame" x="0.0" y="1770" width="1784" height="500"/>
<subviews> <subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YMb-PS-dFz"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YMb-PS-dFz">
<rect key="frame" x="0.0" y="0.0" width="884" height="500"/> <rect key="frame" x="0.0" y="0.0" width="884" height="500"/>
@ -193,7 +206,7 @@
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="myS-g5-vsP"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" translatesAutoresizingMaskIntoConstraints="NO" id="myS-g5-vsP">
<rect key="frame" x="0.0" y="2170" width="1784" height="50"/> <rect key="frame" x="0.0" y="2280" width="1784" height="50"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mDV-nN-W7V" customClass="Label" customModule="TournamentStats" customModuleProvider="target"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mDV-nN-W7V" customClass="Label" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="892" height="50"/> <rect key="frame" x="0.0" y="0.0" width="892" height="50"/>
@ -213,7 +226,7 @@
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="2iy-YX-agg"> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="2iy-YX-agg">
<rect key="frame" x="0.0" y="2230" width="1784" height="400"/> <rect key="frame" x="0.0" y="2340" width="1784" height="400"/>
<subviews> <subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="vqG-Pt-IB2" customClass="TableView" customModule="TournamentStats" customModuleProvider="target"> <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="vqG-Pt-IB2" customClass="TableView" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="884" height="400"/> <rect key="frame" x="0.0" y="0.0" width="884" height="400"/>
@ -240,6 +253,7 @@
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/> <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<connections> <connections>
<outlet property="collectionView" destination="C35-qI-rKP" id="XRC-Q6-W3C"/>
<outlet property="container21" destination="Zmk-PV-di2" id="mv0-Sg-r5V"/> <outlet property="container21" destination="Zmk-PV-di2" id="mv0-Sg-r5V"/>
<outlet property="container22" destination="iQu-2n-Y3T" id="Yhg-KD-vzU"/> <outlet property="container22" destination="iQu-2n-Y3T" id="Yhg-KD-vzU"/>
<outlet property="container23" destination="OZT-Lo-t7S" id="QcZ-kf-CTr"/> <outlet property="container23" destination="OZT-Lo-t7S" id="QcZ-kf-CTr"/>
@ -274,7 +288,7 @@
<outlet property="tableView32" destination="WPJ-0S-klg" id="PzI-hh-uer"/> <outlet property="tableView32" destination="WPJ-0S-klg" id="PzI-hh-uer"/>
<outlet property="tableView51" destination="vqG-Pt-IB2" id="FrK-oS-xF8"/> <outlet property="tableView51" destination="vqG-Pt-IB2" id="FrK-oS-xF8"/>
</connections> </connections>
<point key="canvasLocation" x="142" y="-180"/> <point key="canvasLocation" x="-1700.0000000000002" y="-204.24107142857142"/>
</view> </view>
</objects> </objects>
</document> </document>

@ -0,0 +1,17 @@
//
// StatCollectionViewCell.swift
// TournamentStats
//
// Created by Laurent Morvillier on 27/08/2019.
// Copyright © 2019 Stax River. All rights reserved.
//
import Foundation
import UIKit
class StatCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var valueLabel: UILabel!
}

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Stat" id="Ua3-L2-QPG" customClass="StatCollectionViewCell" customModule="TournamentStats" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="344" height="100"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
<rect key="frame" x="0.0" y="0.0" width="344" height="100"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="M1K-Qd-Z8y" userLabel="Name">
<rect key="frame" x="8" y="8" width="328" height="24"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="zlH-fj-ZZH"/>
</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="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FkP-so-0B7" userLabel="Value">
<rect key="frame" x="8" y="36" width="328" height="56"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</view>
<constraints>
<constraint firstItem="M1K-Qd-Z8y" firstAttribute="top" secondItem="Ua3-L2-QPG" secondAttribute="top" constant="8" id="5ba-YO-Iuh"/>
<constraint firstItem="M1K-Qd-Z8y" firstAttribute="leading" secondItem="Ua3-L2-QPG" secondAttribute="leading" constant="8" id="DNu-yX-KiG"/>
<constraint firstAttribute="trailing" secondItem="M1K-Qd-Z8y" secondAttribute="trailing" constant="8" id="Fib-tI-dzT"/>
<constraint firstItem="FkP-so-0B7" firstAttribute="top" secondItem="M1K-Qd-Z8y" secondAttribute="bottom" constant="4" id="UOR-47-lzI"/>
<constraint firstAttribute="trailing" secondItem="FkP-so-0B7" secondAttribute="trailing" constant="8" id="d3G-1w-NXT"/>
<constraint firstItem="FkP-so-0B7" firstAttribute="leading" secondItem="Ua3-L2-QPG" secondAttribute="leading" constant="8" id="lXd-Fg-DzQ"/>
<constraint firstAttribute="bottom" secondItem="FkP-so-0B7" secondAttribute="bottom" constant="8" id="oum-uT-owE"/>
</constraints>
<viewLayoutGuide key="safeArea" id="K6A-mR-pGE"/>
<size key="customSize" width="344" height="100"/>
<connections>
<outlet property="nameLabel" destination="M1K-Qd-Z8y" id="ygh-W2-ZRS"/>
<outlet property="valueLabel" destination="FkP-so-0B7" id="3Fx-XW-Iwg"/>
</connections>
<point key="canvasLocation" x="-133.33333333333334" y="66.294642857142861"/>
</collectionViewCell>
</objects>
</document>

@ -44,6 +44,17 @@ extension Locale {
class Formatter { class Formatter {
static var standard: NumberFormatter {
let c = NumberFormatter()
c.locale = Locale(identifier: "en_US")
c.usesGroupingSeparator = true
c.groupingSeparator = ","
c.decimalSeparator = "."
c.maximumFractionDigits = 0
c.numberStyle = .decimal
return c
}
static var currency: NumberFormatter { static var currency: NumberFormatter {
let c = NumberFormatter() let c = NumberFormatter()
c.locale = Locale(identifier: "en_US") c.locale = Locale(identifier: "en_US")
@ -123,6 +134,10 @@ extension Int {
extension Double { extension Double {
var formatted: String {
return Formatter.standard.string(from: NSNumber(value: self)) ?? ""
}
var currencyFormatted: String { var currencyFormatted: String {
return Formatter.currency.string(from: NSNumber(value: self)) ?? "" return Formatter.currency.string(from: NSNumber(value: self)) ?? ""
} }

@ -12,6 +12,19 @@ import Realm
class Queries { class Queries {
static func festivalStats(realm: Realm) -> FestivalStats {
let tournaments = realm.objects(Tournament.self)
let stats = FestivalStats()
stats.cumulatedBuyins = tournaments.sum(ofProperty: "buyin")
stats.totalEntries = tournaments.sum(ofProperty: "entries")
stats.totalPrizePool = tournaments.sum(ofProperty: "prizepool")
stats.eventsCount = tournaments.count
return stats
}
static func biggestWinners(realm: Realm) -> [CumulatedResults] { static func biggestWinners(realm: Realm) -> [CumulatedResults] {
let players = realm.objects(Player.self) let players = realm.objects(Player.self)

@ -49,6 +49,7 @@ class ReportGenerator {
} }
var festivalStats: FestivalStats = FestivalStats()
var biggestWinners: [CumulatedResults] = [] var biggestWinners: [CumulatedResults] = []
var mostWins: [CumulatedWins] = [] var mostWins: [CumulatedWins] = []
var mostCashes: [CumulatedResults] = [] var mostCashes: [CumulatedResults] = []
@ -72,6 +73,7 @@ class ReportGenerator {
let realm = try! Realm() let realm = try! Realm()
self.festivalStats = Queries.festivalStats(realm: realm)
self.biggestWinners = Queries.biggestWinners(realm: realm) self.biggestWinners = Queries.biggestWinners(realm: realm)
self.mostWins = Queries.mostWins(realm: realm) self.mostWins = Queries.mostWins(realm: realm)
self.mostCashes = Queries.mostCashes(realm: realm) self.mostCashes = Queries.mostCashes(realm: realm)

@ -15,12 +15,16 @@ class CumulatedResults : HTMLRepresentable, ColumnRepresentable {
var numberOfCashes: Int = 0 var numberOfCashes: Int = 0
var results: [Result] = [] var results: [Result] = []
var winsCount: Int = 0 var winsCount: Int = 0
var mainEventFinalist: Bool = false
init(player: Player, average: Bool = false) { init(player: Player, average: Bool = false) {
self.player = player self.player = player
for result in player.results { for result in player.results {
self.add(result: result) self.add(result: result)
if result.tournaments.first?.number == 73 && result.rank < 10 {
self.mainEventFinalist = true
}
} }
if average { if average {
self.total = self.total / Double(self.numberOfCashes) self.total = self.total / Double(self.numberOfCashes)
@ -43,7 +47,11 @@ class CumulatedResults : HTMLRepresentable, ColumnRepresentable {
} }
func cellValues() -> [String] { func cellValues() -> [String] {
return [self.player.formattedName, self.total.currencyFormatted, "\(self.numberOfCashes)"] var name = self.player.formattedName
if self.mainEventFinalist {
name += " *"
}
return [name, self.total.currencyFormatted, "\(self.numberOfCashes)"]
} }
// static func htmlHeaders() -> String { // static func htmlHeaders() -> String {

@ -0,0 +1,64 @@
//
// FestivalStats.swift
// TournamentStats
//
// Created by Laurent Morvillier on 27/08/2019.
// Copyright © 2019 Stax River. All rights reserved.
//
import Foundation
import UIKit
class FestivalStats : NSObject, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
var eventsCount: Int = 0
var totalPrizePool: Double = 0.0
var totalEntries: Double = 0.0
var cumulatedBuyins: Double = 0.0
// MARK: - UICollectionViewDataSource
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4
}
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 = "Total Events"
value = "\(eventsCount)"
case 1:
name = "Total Prizepool".uppercased()
value = self.totalPrizePool.currencyFormatted
case 2:
name = "Total Entries".uppercased()
value = self.totalEntries.formatted
case 3:
name = "Cumulated Buy-ins".uppercased()
value = self.cumulatedBuyins.currencyFormatted
default:
name = ""
value = ""
}
cell.nameLabel.text = name.uppercased()
cell.valueLabel.text = value
cell.nameLabel.textColor = UIColor.white
cell.valueLabel.textColor = UIColor.white
cell.nameLabel.font = UIFont.systemFont(ofSize: 20.0)
cell.valueLabel.font = UIFont.systemFont(ofSize: 56.0, weight: .thin)
return cell
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 360.0, height: 100.0)
}
}
Loading…
Cancel
Save