diff --git a/README.md b/README.md index 3c56c4f..a340ef2 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,18 @@ # Trap Scoring App -## Generating standings on demand +## Scoring -- Download jar file from the [latest release](https://github.com/mrbusche/trap-scoring/releases) -- You will need [Java 23](https://adoptium.net/) to run the jar file -- Open command prompt to directory with downloaded jar file -- Run `java -jar trap-6.2.0.jar` (make sure you have the correct filename from the release) -- There will be output as the process generates the file -- When finished there will be a file named `leaguedata-${date-string}` generated in the directory you ran the command from +| Discipline | Scoring | Events | Locations | Birds | +|----------------|----------------|--------|-----------|-------| +| Singles | 2 rounds of 25 | 4 | 2 | 200 | +| Doubles | 1 round of 50 | 4 | 2 | 200 | +| Handicap | 2 rounds of 25 | 4 | 2 | 200 | +| American Skeet | 2 rounds of 25 | 4 | 2 | 200 | +| Doubles Skeet | 1 round of 50 | 4 | 2 | 200 | +| Sporting Clay | 1 round of 100 | 3 | 2 | 300 | +| 5-Stand | 1 round of 50 | 4 | 2 | 200 | -## Downloading a daily generated report +## Downloading the daily generated report Every day at 6 AM UTC the report is [generated and uploaded](https://github.com/mrbusche/trap-scoring/actions/workflows/daily-standings.yml). @@ -19,7 +22,15 @@ Every day at 6 AM UTC the report is [generated and uploaded](https://github.com/ 4. Extract the zip file 5. Report will be named `league-data-${todays-date}.xlsx` +## Generating standings on demand + +- Download jar file from the [latest release](https://github.com/mrbusche/trap-scoring/releases) +- You will need [Java 23](https://adoptium.net/) to run the jar file +- Open command prompt to directory with downloaded jar file +- Run `java -jar trap-6.2.0.jar` (make sure you have the correct filename from the release) +- There will be output as the process generates the file +- When finished there will be a file named `leaguedata-${date-string}` generated in the directory you ran the command from + ## Online metabase links -[Singles](https://metabase.sssfonline.com/public/question/8648faf9-42e8-4a9c-b55d-2f251349de7f) | [Doubles](https://metabase.sssfonline.com/public/question/5d5a78a5-2356-477f-b1b8-fe6ee11d25b1) | [Handicap](https://metabase.sssfonline.com/public/question/69ca55d9-3e18-45bc-b57f-73aeb205ece8) | [Skeet](https://metabase.sssfonline.com/public/question/c697d744-0e06-4c3f-a640-fea02f9c9ecd) | [Sporting Clays](https://metabase.sssfonline.com/public/question/2c6edb1a-a7ee-43c2-8180-ad199a57be55) | -[Five Stand](https://metabase.sssfonline.com/public/question/3c5aecf2-a9f2-49b2-a11f-36965cb1a964) | [Doubles Skeet](https://metabase.sssfonline.com/public/question/bdd61066-6e29-4242-b6e9-adf286c2c4ae.csv) +[Singles](https://metabase.sssfonline.com/public/question/8648faf9-42e8-4a9c-b55d-2f251349de7f) | [Doubles](https://metabase.sssfonline.com/public/question/5d5a78a5-2356-477f-b1b8-fe6ee11d25b1) | [Handicap](https://metabase.sssfonline.com/public/question/69ca55d9-3e18-45bc-b57f-73aeb205ece8) | [Skeet](https://metabase.sssfonline.com/public/question/c697d744-0e06-4c3f-a640-fea02f9c9ecd) | [Sporting Clays](https://metabase.sssfonline.com/public/question/2c6edb1a-a7ee-43c2-8180-ad199a57be55) | [Five Stand](https://metabase.sssfonline.com/public/question/3c5aecf2-a9f2-49b2-a11f-36965cb1a964) | [Doubles Skeet](https://metabase.sssfonline.com/public/question/bdd61066-6e29-4242-b6e9-adf286c2c4ae.csv) diff --git a/src/main/java/trap/report/DownloadHelper.java b/src/main/java/trap/report/DownloadHelper.java index 982ec6e..1e12c08 100644 --- a/src/main/java/trap/report/DownloadHelper.java +++ b/src/main/java/trap/report/DownloadHelper.java @@ -17,6 +17,18 @@ public class DownloadHelper { Logger logger = LoggerFactory.getLogger(DownloadHelper.class); + private static Map getFileUrls() { + var fileUrls = new HashMap(); + fileUrls.put("singles", "https://metabase.sssfonline.com/public/question/8648faf9-42e8-4a9c-b55d-2f251349de7f.csv"); + fileUrls.put("doubles", "https://metabase.sssfonline.com/public/question/5d5a78a5-2356-477f-b1b8-fe6ee11d25b1.csv"); + fileUrls.put("handicap", "https://metabase.sssfonline.com/public/question/69ca55d9-3e18-45bc-b57f-73aeb205ece8.csv"); + fileUrls.put("skeet", "https://metabase.sssfonline.com/public/question/c697d744-0e06-4c3f-a640-fea02f9c9ecd.csv"); + fileUrls.put("clays", "https://metabase.sssfonline.com/public/question/2c6edb1a-a7ee-43c2-8180-ad199a57be55.csv"); + fileUrls.put("fivestand", "https://metabase.sssfonline.com/public/question/3c5aecf2-a9f2-49b2-a11f-36965cb1a964.csv"); + fileUrls.put("doublesskeet", "https://metabase.sssfonline.com/public/question/bdd61066-6e29-4242-b6e9-adf286c2c4ae.csv"); + return fileUrls; + } + public void downloadFiles(String[] trapTypes) throws IOException { var start = System.currentTimeMillis(); logger.info("Started downloading files"); @@ -37,16 +49,4 @@ public void downloadFiles(String[] trapTypes) throws IOException { } logger.info("Files downloaded in {} ms", System.currentTimeMillis() - start); } - - private static Map getFileUrls() { - var fileUrls = new HashMap(); - fileUrls.put("singles", "https://metabase.sssfonline.com/public/question/8648faf9-42e8-4a9c-b55d-2f251349de7f.csv"); - fileUrls.put("doubles", "https://metabase.sssfonline.com/public/question/5d5a78a5-2356-477f-b1b8-fe6ee11d25b1.csv"); - fileUrls.put("handicap", "https://metabase.sssfonline.com/public/question/69ca55d9-3e18-45bc-b57f-73aeb205ece8.csv"); - fileUrls.put("skeet", "https://metabase.sssfonline.com/public/question/c697d744-0e06-4c3f-a640-fea02f9c9ecd.csv"); - fileUrls.put("clays", "https://metabase.sssfonline.com/public/question/2c6edb1a-a7ee-43c2-8180-ad199a57be55.csv"); - fileUrls.put("fivestand", "https://metabase.sssfonline.com/public/question/3c5aecf2-a9f2-49b2-a11f-36965cb1a964.csv"); - fileUrls.put("doublesskeet", "https://metabase.sssfonline.com/public/question/bdd61066-6e29-4242-b6e9-adf286c2c4ae.csv"); - return fileUrls; - } } diff --git a/src/main/java/trap/report/TrapHelper.java b/src/main/java/trap/report/TrapHelper.java index 96f646d..785f35f 100644 --- a/src/main/java/trap/report/TrapHelper.java +++ b/src/main/java/trap/report/TrapHelper.java @@ -21,8 +21,57 @@ import static trap.report.ReportHelper.SKEET; public class TrapHelper { - private static final Map eventCounts = determineEventsToCount(); protected static final Map roundCounts = determineRoundsToCount(); + private static final Map eventCounts = determineEventsToCount(); + + private static Map determineEventsToCount() { + var eventCounts = new HashMap(); + eventCounts.put(SINGLES, 4); + eventCounts.put(DOUBLES, 4); + eventCounts.put(HANDICAP, 4); + eventCounts.put(SKEET, 4); + eventCounts.put(CLAYS, 3); + eventCounts.put(FIVESTAND, 4); + eventCounts.put(DOUBLESKEET, 4); + return eventCounts; + } + + public static int getEventsToCount(String type) { + return eventCounts.getOrDefault(type, 0); // Default to 0 if type not found + } + + public static String trimString(String s) { + return s.trim(); + } + + private static Map determineRoundsToCount() { + var roundCounts = new HashMap(); + roundCounts.put(SINGLES, 5); + roundCounts.put(DOUBLES, 5); + roundCounts.put(HANDICAP, 5); + + roundCounts.put(SKEET, 3); + roundCounts.put(CLAYS, 3); + roundCounts.put(FIVESTAND, 3); + roundCounts.put(DOUBLESKEET, 3); + return roundCounts; + } + + public static int getRoundsToCount(String type) { + return roundCounts.getOrDefault(type, 0); // Default to 0 if type not found + } + + public static int parseInteger(String number) { + try { + return Integer.parseInt(number); + } catch (NumberFormatException e) { + return 0; + } + } + + public static int setStringToZero(String number) { + return number.isEmpty() ? 0 : parseInteger(number); + } public Map> calculatePlayerRoundTotals(List roundScores) { Map> playerRoundTotals = new HashMap<>(); @@ -108,7 +157,7 @@ private IndividualTotal toIndividualTotal(RoundTotal t) { } // Method to determine if a round should be added based on location constraints - private boolean shouldAddRound( RoundTotal t, Set locationIds) { + private boolean shouldAddRound(RoundTotal t, Set locationIds) { int locationId = t.getLocationId(); // Check if the location doesn't already exist if (!locationIds.contains(locationId)) { @@ -145,53 +194,4 @@ public boolean singleRound(String roundType) { Set validRounds = Set.of(CLAYS, DOUBLES, DOUBLESKEET, FIVESTAND); return validRounds.contains(roundType); } - - private static Map determineEventsToCount() { - var eventCounts = new HashMap(); - eventCounts.put(SINGLES, 4); - eventCounts.put(DOUBLES, 4); - eventCounts.put(HANDICAP, 4); - eventCounts.put(SKEET, 4); - eventCounts.put(CLAYS, 3); - eventCounts.put(FIVESTAND, 4); - eventCounts.put(DOUBLESKEET, 4); - return eventCounts; - } - - public static int getEventsToCount(String type) { - return eventCounts.getOrDefault(type, 0); // Default to 0 if type not found - } - - public static String trimString(String s) { - return s.trim(); - } - - private static Map determineRoundsToCount() { - var roundCounts = new HashMap(); - roundCounts.put(SINGLES, 5); - roundCounts.put(DOUBLES, 5); - roundCounts.put(HANDICAP, 5); - - roundCounts.put(SKEET, 3); - roundCounts.put(CLAYS, 3); - roundCounts.put(FIVESTAND, 3); - roundCounts.put(DOUBLESKEET, 3); - return roundCounts; - } - - public static int getRoundsToCount(String type) { - return roundCounts.getOrDefault(type, 0); // Default to 0 if type not found - } - - public static int parseInteger(String number) { - try { - return Integer.parseInt(number); - } catch (NumberFormatException e) { - return 0; - } - } - - public static int setStringToZero(String number) { - return number.isEmpty() ? 0 : parseInteger(number); - } }