Skip to content

Commit

Permalink
improve README (#447)
Browse files Browse the repository at this point in the history
* improve README

* fix silly line breaks

* fix more line breaks
  • Loading branch information
mrbusche authored Oct 5, 2024
1 parent 9dacbd2 commit bfc790a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 73 deletions.
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).

Expand All @@ -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)
24 changes: 12 additions & 12 deletions src/main/java/trap/report/DownloadHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
public class DownloadHelper {
Logger logger = LoggerFactory.getLogger(DownloadHelper.class);

private static Map<String, String> getFileUrls() {
var fileUrls = new HashMap<String, String>();
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");
Expand All @@ -37,16 +49,4 @@ public void downloadFiles(String[] trapTypes) throws IOException {
}
logger.info("Files downloaded in {} ms", System.currentTimeMillis() - start);
}

private static Map<String, String> getFileUrls() {
var fileUrls = new HashMap<String, String>();
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;
}
}
102 changes: 51 additions & 51 deletions src/main/java/trap/report/TrapHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,57 @@
import static trap.report.ReportHelper.SKEET;

public class TrapHelper {
private static final Map<String, Integer> eventCounts = determineEventsToCount();
protected static final Map<String, Integer> roundCounts = determineRoundsToCount();
private static final Map<String, Integer> eventCounts = determineEventsToCount();

private static Map<String, Integer> determineEventsToCount() {
var eventCounts = new HashMap<String, Integer>();
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<String, Integer> determineRoundsToCount() {
var roundCounts = new HashMap<String, Integer>();
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<String, List<RoundTotal>> calculatePlayerRoundTotals(List<RoundScore> roundScores) {
Map<String, List<RoundTotal>> playerRoundTotals = new HashMap<>();
Expand Down Expand Up @@ -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<Integer> locationIds) {
private boolean shouldAddRound(RoundTotal t, Set<Integer> locationIds) {
int locationId = t.getLocationId();
// Check if the location doesn't already exist
if (!locationIds.contains(locationId)) {
Expand Down Expand Up @@ -145,53 +194,4 @@ public boolean singleRound(String roundType) {
Set<String> validRounds = Set.of(CLAYS, DOUBLES, DOUBLESKEET, FIVESTAND);
return validRounds.contains(roundType);
}

private static Map<String, Integer> determineEventsToCount() {
var eventCounts = new HashMap<String, Integer>();
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<String, Integer> determineRoundsToCount() {
var roundCounts = new HashMap<String, Integer>();
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);
}
}

0 comments on commit bfc790a

Please sign in to comment.