From 11d6788acc94f57a0b2e68bf418d6ca0b2a4f723 Mon Sep 17 00:00:00 2001 From: Matt Busche Date: Sun, 22 Sep 2024 16:31:12 -0500 Subject: [PATCH 1/6] Updates for skeets and doubles skeet --- src/main/java/trap/report/TrapHelper.java | 4 +- src/test/java/trap/report/TrapHelperTest.java | 62 ++++++++++++++++--- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/main/java/trap/report/TrapHelper.java b/src/main/java/trap/report/TrapHelper.java index 2e03f84..c39c9d6 100644 --- a/src/main/java/trap/report/TrapHelper.java +++ b/src/main/java/trap/report/TrapHelper.java @@ -102,10 +102,10 @@ private static Map determineRoundsToCount() { roundCounts.put("singles", 4); roundCounts.put("doubles", 4); roundCounts.put("handicap", 4); - roundCounts.put("skeet", 3); + roundCounts.put("skeet", 4); roundCounts.put("clays", 3); roundCounts.put("fivestand", 3); - roundCounts.put("doublesskeet", 3); + roundCounts.put("doublesskeet", 4); return roundCounts; } diff --git a/src/test/java/trap/report/TrapHelperTest.java b/src/test/java/trap/report/TrapHelperTest.java index 99243d1..9376356 100644 --- a/src/test/java/trap/report/TrapHelperTest.java +++ b/src/test/java/trap/report/TrapHelperTest.java @@ -527,6 +527,7 @@ void skeetScoring3Locations() { roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 24, 24, 0, 0, 0, 0, 0, 0, "skeet")); roundScores.add(new RoundScore(16940, "Event 2", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 23, 22, 0, 0, 0, 0, 0, 0, "skeet")); roundScores.add(new RoundScore(17159, "Event 4", 986, "Location 4", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 21, 23, 0, 0, 0, 0, 0, 0, "skeet")); + roundScores.add(new RoundScore(17159, "Event 4", 986, "Location 4", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 21, 23, 0, 0, 0, 0, 0, 0, "skeet")); var playerRoundTotals = trapHelper.calculatePlayerRoundTotals(roundScores); var playerIndividualTotal = trapHelper.calculatePlayerIndividualTotal(roundScores, playerRoundTotals); @@ -538,7 +539,7 @@ void skeetScoring3Locations() { assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); - assertEquals(137, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals(181, playerFinalTotal.get(player1.getUniqueName()).getTotal()); assertEquals("skeet", playerFinalTotal.get(player1.getUniqueName()).getType()); } @@ -561,7 +562,7 @@ void skeetScoring2Locations() { assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); - assertEquals(137, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals(179, playerFinalTotal.get(player1.getUniqueName()).getTotal()); assertEquals("skeet", playerFinalTotal.get(player1.getUniqueName()).getType()); } @@ -587,7 +588,7 @@ void skeetScoring2LocationsWithHigherScoresInOneLocation() { assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); - assertEquals(141, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals(189, playerFinalTotal.get(player1.getUniqueName()).getTotal()); assertEquals("skeet", playerFinalTotal.get(player1.getUniqueName()).getType()); } @@ -639,12 +640,36 @@ void claysScoring3LocationsWithHigherScoresInOneLocation() { assertEquals("clays", playerFinalTotal.get(player1.getUniqueName()).getType()); } + @Test + void doublesskeetScoring4Locations() { + var roundScores = new ArrayList(); + + roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 23, 0, 0, 0, 0, 0, 0, "doublesskeet")); + roundScores.add(new RoundScore(16940, "Event 2", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 45, 22, 0, 0, 0, 0, 0, 0, "doublesskeet")); + roundScores.add(new RoundScore(17159, "Event 3", 123, "Location 3", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "doublesskeet")); + roundScores.add(new RoundScore(17159, "Event 4", 24, "Location 4", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "doublesskeet")); + + var playerRoundTotals = trapHelper.calculatePlayerRoundTotals(roundScores); + var playerIndividualTotal = trapHelper.calculatePlayerIndividualTotal(roundScores, playerRoundTotals); + var playerFinalTotal = trapHelper.calculatePlayerFinalTotal(playerIndividualTotal); + + var player1 = roundScores.getFirst(); + assertEquals(0, playerFinalTotal.get(player1.getUniqueName()).getLocationId()); + assertEquals("Team Name", playerFinalTotal.get(player1.getUniqueName()).getTeam()); + assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); + assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); + assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); + assertEquals(181, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals("doublesskeet", playerFinalTotal.get(player1.getUniqueName()).getType()); + } + @Test void doublesskeetScoring3Locations() { var roundScores = new ArrayList(); roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 23, 0, 0, 0, 0, 0, 0, "doublesskeet")); roundScores.add(new RoundScore(16940, "Event 2", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 45, 22, 0, 0, 0, 0, 0, 0, "doublesskeet")); + roundScores.add(new RoundScore(17159, "Event 3", 123, "Location 3", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "doublesskeet")); roundScores.add(new RoundScore(17159, "Event 4", 123, "Location 4", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "doublesskeet")); var playerRoundTotals = trapHelper.calculatePlayerRoundTotals(roundScores); @@ -657,7 +682,30 @@ void doublesskeetScoring3Locations() { assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); - assertEquals(137, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals(181, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals("doublesskeet", playerFinalTotal.get(player1.getUniqueName()).getType()); + } + + @Test + void doublesskeetScoring2Locations() { + var roundScores = new ArrayList(); + + roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 23, 0, 0, 0, 0, 0, 0, "doublesskeet")); + roundScores.add(new RoundScore(16940, "Event 2", 986, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 45, 22, 0, 0, 0, 0, 0, 0, "doublesskeet")); + roundScores.add(new RoundScore(17159, "Event 3", 123, "Location 3", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "doublesskeet")); + roundScores.add(new RoundScore(17159, "Event 4", 123, "Location 4", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "doublesskeet")); + + var playerRoundTotals = trapHelper.calculatePlayerRoundTotals(roundScores); + var playerIndividualTotal = trapHelper.calculatePlayerIndividualTotal(roundScores, playerRoundTotals); + var playerFinalTotal = trapHelper.calculatePlayerFinalTotal(playerIndividualTotal); + + var player1 = roundScores.getFirst(); + assertEquals(0, playerFinalTotal.get(player1.getUniqueName()).getLocationId()); + assertEquals("Team Name", playerFinalTotal.get(player1.getUniqueName()).getTeam()); + assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); + assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); + assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); + assertEquals(181, playerFinalTotal.get(player1.getUniqueName()).getTotal()); assertEquals("doublesskeet", playerFinalTotal.get(player1.getUniqueName()).getType()); } @@ -683,7 +731,7 @@ void doublesskeetScoring3LocationsWithHigherScoresInOneLocation() { assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); - assertEquals(141, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals(189, playerFinalTotal.get(player1.getUniqueName()).getTotal()); assertEquals("doublesskeet", playerFinalTotal.get(player1.getUniqueName()).getType()); } @@ -741,9 +789,9 @@ void roundsToCount() { assertEquals(4, TrapHelper.getRoundsToCount("doubles")); assertEquals(4, TrapHelper.getRoundsToCount("handicap")); - assertEquals(3, TrapHelper.getRoundsToCount("skeet")); + assertEquals(4, TrapHelper.getRoundsToCount("skeet")); assertEquals(3, TrapHelper.getRoundsToCount("clays")); assertEquals(3, TrapHelper.getRoundsToCount("fivestand")); - assertEquals(3, TrapHelper.getRoundsToCount("doublesskeet")); + assertEquals(4, TrapHelper.getRoundsToCount("doublesskeet")); } } From 9dd4961636d5636ba49f9ef2eeecf092d51d180e Mon Sep 17 00:00:00 2001 From: Matt Busche Date: Sun, 22 Sep 2024 16:40:45 -0500 Subject: [PATCH 2/6] Update clays and five stand --- src/main/java/trap/report/TrapHelper.java | 14 ++-- src/test/java/trap/report/TrapHelperTest.java | 80 +++++++++++-------- 2 files changed, 55 insertions(+), 39 deletions(-) diff --git a/src/main/java/trap/report/TrapHelper.java b/src/main/java/trap/report/TrapHelper.java index c39c9d6..f13607e 100644 --- a/src/main/java/trap/report/TrapHelper.java +++ b/src/main/java/trap/report/TrapHelper.java @@ -49,7 +49,7 @@ public Map> calculatePlayerIndividualTotal(Li playerIndividualTotal.put(r.getUniqueName(), new ArrayList<>()); } for (var playerRoundTotal : playerRoundTotals.values()) { - var roundsToCount = getRoundsToCount(playerRoundTotal.getFirst().getType()); + var roundsToCount = getEventsToCount(playerRoundTotal.getFirst().getType()); var indTotal = new ArrayList(); playerRoundTotal.sort(Comparator.comparingInt(RoundTotal::getTotal).reversed()); for (var t : playerRoundTotal) { @@ -93,23 +93,23 @@ public Map calculatePlayerFinalTotal(Map determineRoundsToCount() { + private static Map determineEventsToCount() { var roundCounts = new HashMap(); roundCounts.put("singles", 4); roundCounts.put("doubles", 4); roundCounts.put("handicap", 4); roundCounts.put("skeet", 4); roundCounts.put("clays", 3); - roundCounts.put("fivestand", 3); + roundCounts.put("fivestand", 4); roundCounts.put("doublesskeet", 4); return roundCounts; } - public static int getRoundsToCount(String type) { - return Integer.parseInt(determineRoundsToCount().get(type).toString()); + public static int getEventsToCount(String type) { + return Integer.parseInt(determineEventsToCount().get(type).toString()); } } diff --git a/src/test/java/trap/report/TrapHelperTest.java b/src/test/java/trap/report/TrapHelperTest.java index 9376356..d5f2ad7 100644 --- a/src/test/java/trap/report/TrapHelperTest.java +++ b/src/test/java/trap/report/TrapHelperTest.java @@ -8,6 +8,8 @@ import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; @SpringBootTest class TrapHelperTest { @@ -596,9 +598,9 @@ void skeetScoring2LocationsWithHigherScoresInOneLocation() { void claysScoring3Locations() { var roundScores = new ArrayList(); - roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 23, 0, 0, 0, 0, 0, 0, "clays")); - roundScores.add(new RoundScore(16940, "Event 2", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 45, 22, 0, 0, 0, 0, 0, 0, "clays")); - roundScores.add(new RoundScore(17159, "Event 4", 123, "Location 4", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 96, 23, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(16940, "Event 2", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 93, 22, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(17159, "Event 4", 123, "Location 4", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 88, 23, 0, 0, 0, 0, 0, 0, "clays")); var playerRoundTotals = trapHelper.calculatePlayerRoundTotals(roundScores); var playerIndividualTotal = trapHelper.calculatePlayerIndividualTotal(roundScores, playerRoundTotals); @@ -610,7 +612,7 @@ void claysScoring3Locations() { assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); - assertEquals(137, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals(277, playerFinalTotal.get(player1.getUniqueName()).getTotal()); assertEquals("clays", playerFinalTotal.get(player1.getUniqueName()).getType()); } @@ -618,13 +620,13 @@ void claysScoring3Locations() { void claysScoring3LocationsWithHigherScoresInOneLocation() { var roundScores = new ArrayList(); - roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 44, 0, 0, 0, 0, 0, 0, "clays")); - roundScores.add(new RoundScore(16943, "Event 2", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 44, 0, 0, 0, 0, 0, 0, "clays")); - roundScores.add(new RoundScore(16953, "Event 3", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 44, 0, 0, 0, 0, 0, 0, "clays")); - roundScores.add(new RoundScore(16963, "Event 4", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 44, 0, 0, 0, 0, 0, 0, "clays")); - roundScores.add(new RoundScore(16973, "Event 5", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 44, 0, 0, 0, 0, 0, 0, "clays")); - roundScores.add(new RoundScore(16940, "Event 6", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 45, 22, 0, 0, 0, 0, 0, 0, "clays")); - roundScores.add(new RoundScore(18168, "Event 7", 12, "Location 6", "2023-04-09", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 96, 88, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(16943, "Event 2", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 96, 88, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(16953, "Event 3", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 96, 88, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(16963, "Event 4", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 96, 88, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(16973, "Event 5", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 96, 88, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(16940, "Event 6", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 90, 22, 0, 0, 0, 0, 0, 0, "clays")); + roundScores.add(new RoundScore(18168, "Event 7", 12, "Location 6", "2023-04-09", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 88, 23, 0, 0, 0, 0, 0, 0, "clays")); var playerRoundTotals = trapHelper.calculatePlayerRoundTotals(roundScores); var playerIndividualTotal = trapHelper.calculatePlayerIndividualTotal(roundScores, playerRoundTotals); @@ -636,7 +638,7 @@ void claysScoring3LocationsWithHigherScoresInOneLocation() { assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); - assertEquals(141, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals(282, playerFinalTotal.get(player1.getUniqueName()).getTotal()); assertEquals("clays", playerFinalTotal.get(player1.getUniqueName()).getType()); } @@ -739,9 +741,10 @@ void doublesskeetScoring3LocationsWithHigherScoresInOneLocation() { void fivestandScoring3Locations() { var roundScores = new ArrayList(); - roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 25, 23, 0, 0, 0, 0, 0, 0, "fivestand")); - roundScores.add(new RoundScore(16940, "Event 2", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 23, 22, 0, 0, 0, 0, 0, 0, "fivestand")); - roundScores.add(new RoundScore(17159, "Event 4", 123, "Location 4", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 21, 23, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 23, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(16940, "Event 2", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 45, 22, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(17159, "Event 3", 123, "Location 3", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(17159, "Event 4", 123, "Location 4", "2022-09-24", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 50, 23, 0, 0, 0, 0, 0, 0, "fivestand")); var playerRoundTotals = trapHelper.calculatePlayerRoundTotals(roundScores); var playerIndividualTotal = trapHelper.calculatePlayerIndividualTotal(roundScores, playerRoundTotals); @@ -753,7 +756,7 @@ void fivestandScoring3Locations() { assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); - assertEquals(137, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals(187, playerFinalTotal.get(player1.getUniqueName()).getTotal()); assertEquals("fivestand", playerFinalTotal.get(player1.getUniqueName()).getType()); } @@ -761,13 +764,13 @@ void fivestandScoring3Locations() { void fivestandScoring3LocationsWithHigherScoresInOneLocation() { var roundScores = new ArrayList(); - roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 24, 24, 0, 0, 0, 0, 0, 0, "fivestand")); - roundScores.add(new RoundScore(16943, "Event 2", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 24, 24, 0, 0, 0, 0, 0, 0, "fivestand")); - roundScores.add(new RoundScore(16953, "Event 3", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 24, 24, 0, 0, 0, 0, 0, 0, "fivestand")); - roundScores.add(new RoundScore(16963, "Event 4", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 24, 24, 0, 0, 0, 0, 0, 0, "fivestand")); - roundScores.add(new RoundScore(16973, "Event 5", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 24, 24, 0, 0, 0, 0, 0, 0, "fivestand")); - roundScores.add(new RoundScore(16940, "Event 6", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 23, 22, 0, 0, 0, 0, 0, 0, "fivestand")); - roundScores.add(new RoundScore(18168, "Event 7", 12, "Location 6", "2023-04-09", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 21, 23, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(16933, "Event 1", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 24, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(16943, "Event 2", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 24, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(16953, "Event 3", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 24, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(16963, "Event 4", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 24, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(16973, "Event 5", 986, "Location 1", "2022-09-03", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 48, 24, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(16940, "Event 6", 50, "Location 2", "2022-09-11", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 45, 22, 0, 0, 0, 0, 0, 0, "fivestand")); + roundScores.add(new RoundScore(18168, "Event 7", 12, "Location 6", "2023-04-09", "Squad Name", "Team Name", "Sam LaPorta", "Senior/Varsity", "M", 44, 23, 0, 0, 0, 0, 0, 0, "fivestand")); var playerRoundTotals = trapHelper.calculatePlayerRoundTotals(roundScores); var playerIndividualTotal = trapHelper.calculatePlayerIndividualTotal(roundScores, playerRoundTotals); @@ -779,19 +782,32 @@ void fivestandScoring3LocationsWithHigherScoresInOneLocation() { assertEquals("Sam LaPorta", playerFinalTotal.get(player1.getUniqueName()).getAthlete()); assertEquals("Senior/Varsity", playerFinalTotal.get(player1.getUniqueName()).getClassification()); assertEquals("M", playerFinalTotal.get(player1.getUniqueName()).getGender()); - assertEquals(141, playerFinalTotal.get(player1.getUniqueName()).getTotal()); + assertEquals(189, playerFinalTotal.get(player1.getUniqueName()).getTotal()); assertEquals("fivestand", playerFinalTotal.get(player1.getUniqueName()).getType()); } + @Test + void eventsToCount() { + assertEquals(4, TrapHelper.getEventsToCount("singles")); + assertEquals(4, TrapHelper.getEventsToCount("doubles")); + assertEquals(4, TrapHelper.getEventsToCount("handicap")); + assertEquals(4, TrapHelper.getEventsToCount("skeet")); + assertEquals(4, TrapHelper.getEventsToCount("fivestand")); + assertEquals(4, TrapHelper.getEventsToCount("doublesskeet")); + + assertEquals(3, TrapHelper.getEventsToCount("clays")); + } + @Test void roundsToCount() { - assertEquals(4, TrapHelper.getRoundsToCount("singles")); - assertEquals(4, TrapHelper.getRoundsToCount("doubles")); - assertEquals(4, TrapHelper.getRoundsToCount("handicap")); - - assertEquals(4, TrapHelper.getRoundsToCount("skeet")); - assertEquals(3, TrapHelper.getRoundsToCount("clays")); - assertEquals(3, TrapHelper.getRoundsToCount("fivestand")); - assertEquals(4, TrapHelper.getRoundsToCount("doublesskeet")); + assertTrue(trapHelper.singleRound("clays")); + assertTrue(trapHelper.singleRound("doubles")); + assertTrue(trapHelper.singleRound("fivestand")); + assertTrue(trapHelper.singleRound("doublesskeet")); + + assertFalse(trapHelper.singleRound("singles")); + assertFalse(trapHelper.singleRound("handicap")); + assertFalse(trapHelper.singleRound("skeet")); + } } From f9fadaa3da6307933e27bd26ee82cf0f59713642 Mon Sep 17 00:00:00 2001 From: Matt Busche Date: Sun, 22 Sep 2024 16:47:54 -0500 Subject: [PATCH 3/6] minor cleanups --- src/main/java/trap/report/TrapHelper.java | 38 ++++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main/java/trap/report/TrapHelper.java b/src/main/java/trap/report/TrapHelper.java index f13607e..18c1dd0 100644 --- a/src/main/java/trap/report/TrapHelper.java +++ b/src/main/java/trap/report/TrapHelper.java @@ -10,8 +10,10 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; public class TrapHelper { + private static final Map roundCounts = determineEventsToCount(); public Map> calculatePlayerRoundTotals(List roundScores) { var playerRoundTotals = new HashMap>(); @@ -76,25 +78,31 @@ public Map> calculatePlayerIndividualTotal(Li return playerIndividualTotal; } - public Map calculatePlayerFinalTotal(Map> playerIndividualTotal) { - var playerFinalTotal = new HashMap(); - for (Map.Entry> entry : playerIndividualTotal.entrySet()) { - var key = entry.getKey(); - ArrayList value = entry.getValue(); - if (!value.isEmpty()) { - int total = 0; - for (var t : value) { - total += t.getTotal(); - } - playerFinalTotal.put(key, new IndividualTotal(0, value.getFirst().getTeam(), value.getFirst().getAthlete(), value.getFirst().getClassification(), value.getFirst().getGender(), total, value.getFirst().getType())); + public Map calculatePlayerFinalTotal(Map> playerIndividualTotals) { + var playerFinalTotals = new HashMap(); + playerIndividualTotals.forEach((key, totals) -> { + if (!totals.isEmpty()) { + var firstTotal = totals.get(0); + int totalScore = totals.stream().mapToInt(IndividualTotal::getTotal).sum(); + + playerFinalTotals.put(key, new IndividualTotal( + 0, + firstTotal.getTeam(), + firstTotal.getAthlete(), + firstTotal.getClassification(), + firstTotal.getGender(), + totalScore, + firstTotal.getType() + )); } - } + }); - return playerFinalTotal; + return playerFinalTotals; } public boolean singleRound(String roundType) { - return roundType.equals("clays") || roundType.equals("doubles") || roundType.equals("doublesskeet") || roundType.equals("fivestand"); + Set validRounds = Set.of("clays", "doubles", "doublesskeet", "fivestand"); + return validRounds.contains(roundType); } private static Map determineEventsToCount() { @@ -110,6 +118,6 @@ private static Map determineEventsToCount() { } public static int getEventsToCount(String type) { - return Integer.parseInt(determineEventsToCount().get(type).toString()); + return roundCounts.getOrDefault(type, 0); // Default to 0 if type not found } } From 9cf97f62fda0aaf87617cbe0b7cd85e3e14524d8 Mon Sep 17 00:00:00 2001 From: Matt Busche Date: Sun, 22 Sep 2024 16:57:04 -0500 Subject: [PATCH 4/6] more cleanups --- src/main/java/trap/report/TrapHelper.java | 74 ++++++++++++++--------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/src/main/java/trap/report/TrapHelper.java b/src/main/java/trap/report/TrapHelper.java index 18c1dd0..696d252 100644 --- a/src/main/java/trap/report/TrapHelper.java +++ b/src/main/java/trap/report/TrapHelper.java @@ -15,8 +15,8 @@ public class TrapHelper { private static final Map roundCounts = determineEventsToCount(); - public Map> calculatePlayerRoundTotals(List roundScores) { - var playerRoundTotals = new HashMap>(); + public Map> calculatePlayerRoundTotals(List roundScores) { + var playerRoundTotals = new HashMap>(); for (var r : roundScores) { playerRoundTotals.put(r.getUniqueName(), new ArrayList<>()); } @@ -45,40 +45,58 @@ public Map> calculatePlayerRoundTotals(List> calculatePlayerIndividualTotal(List roundScores, Map> playerRoundTotals) { - var playerIndividualTotal = new HashMap>(); - for (var r : roundScores) { - playerIndividualTotal.put(r.getUniqueName(), new ArrayList<>()); - } - for (var playerRoundTotal : playerRoundTotals.values()) { - var roundsToCount = getEventsToCount(playerRoundTotal.getFirst().getType()); - var indTotal = new ArrayList(); + public Map> calculatePlayerIndividualTotal(List roundScores, Map> playerRoundTotals) { + Map> playerIndividualTotal = new HashMap<>(); + + // Initialize scores with empty lists + roundScores.forEach(r -> playerIndividualTotal.put(r.getUniqueName(), new ArrayList<>())); + + for (List playerRoundTotal : playerRoundTotals.values()) { + if (playerRoundTotal.isEmpty()) continue; + + String playerName = playerRoundTotal.get(0).getUniqueName(); + int roundsToCount = getEventsToCount(playerRoundTotal.get(0).getType()); + List indTotal = new ArrayList<>(); + + // Sort in descending order based on total score playerRoundTotal.sort(Comparator.comparingInt(RoundTotal::getTotal).reversed()); - for (var t : playerRoundTotal) { - if (indTotal.size() < (roundsToCount - 1)) { - indTotal.add(new IndividualTotal(t.getLocationId(), t.getTeam(), t.getAthlete(), t.getClassification(), t.getGender(), t.getTotal(), t.getType())); - } else { - var locationIds = new HashSet(); - indTotal.forEach(l -> locationIds.add(l.getLocationId())); - // if location doesn't already exist - if (!locationIds.contains(t.getLocationId())) { - indTotal.add(new IndividualTotal(t.getLocationId(), t.getTeam(), t.getAthlete(), t.getClassification(), t.getGender(), t.getTotal(), t.getType())); - break; - } - // if location isn't the same as the other 3 - if (locationIds.size() == 2 || locationIds.size() == 3) { - indTotal.add(new IndividualTotal(t.getLocationId(), t.getTeam(), t.getAthlete(), t.getClassification(), t.getGender(), t.getTotal(), t.getType())); - break; - } + + Set locationIds = new HashSet<>(); + for (RoundTotal t : playerRoundTotal) { + if (indTotal.size() < roundsToCount - 1) { + // Add round directly until we reach the number of rounds to count + indTotal.add(toIndividualTotal(t)); + locationIds.add(t.getLocationId()); + } else if (shouldAddRound(indTotal, t, locationIds)) { + // Handle special case when location constraints are applied + indTotal.add(toIndividualTotal(t)); + break; } } - playerIndividualTotal.put(playerRoundTotal.getFirst().getUniqueName(), indTotal); + + playerIndividualTotal.put(playerName, indTotal); } return playerIndividualTotal; } - public Map calculatePlayerFinalTotal(Map> playerIndividualTotals) { + private IndividualTotal toIndividualTotal(RoundTotal t) { + return new IndividualTotal(t.getLocationId(), t.getTeam(), t.getAthlete(), t.getClassification(), t.getGender(), t.getTotal(), t.getType()); + } + + // Method to determine if a round should be added based on location constraints + private boolean shouldAddRound(List indTotal, RoundTotal t, Set locationIds) { + int locationId = t.getLocationId(); + // Check if the location doesn't already exist + if (!locationIds.contains(locationId)) { + locationIds.add(locationId); + return true; + } + // If there are already 2 or 3 unique locations, consider adding the round + return locationIds.size() == 2 || locationIds.size() == 3; + } + + public Map calculatePlayerFinalTotal(Map> playerIndividualTotals) { var playerFinalTotals = new HashMap(); playerIndividualTotals.forEach((key, totals) -> { if (!totals.isEmpty()) { From 5ad7e856c34c424eb2c4df8905f1840ece6d5128 Mon Sep 17 00:00:00 2001 From: Matt Busche Date: Sun, 22 Sep 2024 17:23:06 -0500 Subject: [PATCH 5/6] more refactoring for newer java features --- src/main/java/trap/report/ExcelHelper.java | 27 +++++--- src/main/java/trap/report/ReportHelper.java | 73 ++++++++++++++++----- src/main/java/trap/report/TrapHelper.java | 62 ++++++++++------- 3 files changed, 112 insertions(+), 50 deletions(-) diff --git a/src/main/java/trap/report/ExcelHelper.java b/src/main/java/trap/report/ExcelHelper.java index 42da4d0..e997832 100644 --- a/src/main/java/trap/report/ExcelHelper.java +++ b/src/main/java/trap/report/ExcelHelper.java @@ -58,18 +58,25 @@ public static void setCurrentSeasonHeader(Sheet sheet) { public static void createFile(Workbook workbook) throws IOException { long start = System.currentTimeMillis(); + String filename = generateFilename(); + + logger.info("Creating file: {}", filename); + try (FileOutputStream fileOutputStream = new FileOutputStream(filename)) { + logger.info("Writing file..."); + workbook.write(fileOutputStream); + logger.info("File written successfully."); + } catch (IOException e) { + logger.error("Error writing file: {}", e.getMessage()); + throw e; + } + + logger.info("Created file in {} ms", System.currentTimeMillis() - start); + } + + private static String generateFilename() { var formatter = new SimpleDateFormat("yyyyMMddHHmmss"); var currentDate = formatter.format(new Date()); - var filename = "league-data-" + currentDate + ".xlsx"; - logger.info("Creating file"); - FileOutputStream fileOutputStream = new FileOutputStream(filename); - logger.info("Writing file"); - workbook.write(fileOutputStream); - logger.info("closing output stream"); - fileOutputStream.flush(); - fileOutputStream.close(); - logger.info("Created file {}", filename); - logger.info("Wrote the contents to a file in {} ms", System.currentTimeMillis() - start); + return "league-data-" + currentDate + ".xlsx"; } public static void addCleanData(Row row, RoundScore rowData) { diff --git a/src/main/java/trap/report/ReportHelper.java b/src/main/java/trap/report/ReportHelper.java index 50b0b91..48948bf 100644 --- a/src/main/java/trap/report/ReportHelper.java +++ b/src/main/java/trap/report/ReportHelper.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.stream.Collectors; @Service public class ReportHelper { @@ -99,16 +100,18 @@ public void generateExcelFile() throws Exception { } private List generateRoundScores() { - List allRoundScores; try { - allRoundScores = new ArrayList<>(); - for (var type : trapTypes) { - allRoundScores.addAll(generateRoundScores(type)); - } - - return allRoundScores; - } catch (IOException | CsvException e) { - throw new RuntimeException(e); + return Arrays.stream(trapTypes) + .flatMap(type -> { + try { + return generateRoundScores(type).stream(); + } catch (IOException | CsvException e) { + throw new RuntimeException("Error generating round scores for type: " + type, e); + } + }) + .toList(); + } catch (RuntimeException e) { + throw new RuntimeException("Error generating round scores", e); } } @@ -118,12 +121,41 @@ private Workbook getWorkbook() throws IOException { } private List generateRoundScores(String type) throws IOException, CsvException { - var reader = new CSVReader(new FileReader(type + ".csv")); - var roundScores = reader.readAll(); - roundScores.removeFirst(); - var roundScoresList = new ArrayList(); - roundScores.forEach(s -> roundScoresList.add(new RoundScore(Integer.parseInt(s[1]), trimString(s[2]), Integer.parseInt(s[3]), trimString(s[4]), trimString(s[5]), trimString(s[6]), trimString(s[7]).replace("Club", "Team"), trimString(s[8]), trimString(s[10]), trimString(s[11]), setStringToZero(s[12]), setStringToZero(s[13]), setStringToZero(s[14]), setStringToZero(s[15]), setStringToZero(s[16]), setStringToZero(s[17]), setStringToZero(s[18]), setStringToZero(s[19]), type))); - return roundScoresList; + try (var reader = new CSVReader(new FileReader(type + ".csv"))) { + var roundScores = reader.readAll(); + if (roundScores.isEmpty()) { + return new ArrayList<>(); // or handle as appropriate + } + roundScores.removeFirst(); // Remove the header row + + return roundScores.stream() + .map(s -> createRoundScore(s, type)) + .toList(); + } + } + + private RoundScore createRoundScore(String[] data, String type) { + return new RoundScore( + parseInteger(data[1]), + trimString(data[2]), + parseInteger(data[3]), + trimString(data[4]), + trimString(data[5]), + trimString(data[6]), + trimString(data[7]).replace("Club", "Team"), + trimString(data[8]), + trimString(data[10]), + trimString(data[11]), + setStringToZero(data[12]), + setStringToZero(data[13]), + setStringToZero(data[14]), + setStringToZero(data[15]), + setStringToZero(data[16]), + setStringToZero(data[17]), + setStringToZero(data[18]), + setStringToZero(data[19]), + type + ); } private void populateCleanData(Sheet sheet, List allRoundScores) { @@ -309,6 +341,7 @@ private List getTeamScoresByTotal(Map return teamScoresByTotal; } + // Team-Individual-Scores tab private void populateTeamIndividualData(Workbook workbook, String sheetName, List teamScoresByTotal) { var sheet = workbook.getSheet(sheetName); var startTime = System.currentTimeMillis(); @@ -351,8 +384,16 @@ private void populateAllIndividualData(Workbook workbook, String sheetName, Map< logger.info("Individual All Scores data populated in {} ms", System.currentTimeMillis() - trueStart); } + private int parseInteger(String number) { + try { + return Integer.parseInt(number); + } catch (NumberFormatException e) { + return 0; + } + } + private int setStringToZero(String number) { - return "".equals(number) ? 0 : Integer.parseInt(number); + return number.isEmpty() ? 0 : parseInteger(number); } private String trimString(String s) { diff --git a/src/main/java/trap/report/TrapHelper.java b/src/main/java/trap/report/TrapHelper.java index 696d252..8acda00 100644 --- a/src/main/java/trap/report/TrapHelper.java +++ b/src/main/java/trap/report/TrapHelper.java @@ -16,35 +16,49 @@ public class TrapHelper { private static final Map roundCounts = determineEventsToCount(); public Map> calculatePlayerRoundTotals(List roundScores) { - var playerRoundTotals = new HashMap>(); - for (var r : roundScores) { - playerRoundTotals.put(r.getUniqueName(), new ArrayList<>()); - } - for (var r : roundScores) { - var currentPlayerRoundTotal = playerRoundTotals.get(r.getUniqueName()); + Map> playerRoundTotals = new HashMap<>(); + + // Initialize map with empty lists for each unique player + roundScores.forEach(r -> playerRoundTotals.put(r.getUniqueName(), new ArrayList<>())); + + // Process each round score + for (RoundScore r : roundScores) { + List currentPlayerRoundTotal = playerRoundTotals.get(r.getUniqueName()); + + // If it's a single round, process round 1 and optionally round 2 if (singleRound(r.getType())) { - currentPlayerRoundTotal.add(new RoundTotal(r.getEventId(), r.getLocationId(), r.getTeam(), r.getAthlete(), r.getClassification(), r.getGender(), r.getRound1(), r.getType())); + addRound(currentPlayerRoundTotal, r, r.getRound1()); if (r.getRound2() > 0) { - currentPlayerRoundTotal.add(new RoundTotal(r.getEventId(), r.getLocationId(), r.getTeam(), r.getAthlete(), r.getClassification(), r.getGender(), r.getRound2(), r.getType())); + addRound(currentPlayerRoundTotal, r, r.getRound2()); } } else { - currentPlayerRoundTotal.add(new RoundTotal(r.getEventId(), r.getLocationId(), r.getTeam(), r.getAthlete(), r.getClassification(), r.getGender(), r.getRound1() + r.getRound2(), r.getType())); - if (r.getRound3() + r.getRound4() > 0) { - currentPlayerRoundTotal.add(new RoundTotal(r.getEventId(), r.getLocationId(), r.getTeam(), r.getAthlete(), r.getClassification(), r.getGender(), r.getRound3() + r.getRound4(), r.getType())); - if (r.getRound5() + r.getRound6() > 0) { - currentPlayerRoundTotal.add(new RoundTotal(r.getEventId(), r.getLocationId(), r.getTeam(), r.getAthlete(), r.getClassification(), r.getGender(), r.getRound5() + r.getRound6(), r.getType())); - if (r.getRound7() + r.getRound8() > 0) { - currentPlayerRoundTotal.add(new RoundTotal(r.getEventId(), r.getLocationId(), r.getTeam(), r.getAthlete(), r.getClassification(), r.getGender(), r.getRound7() + r.getRound8(), r.getType())); - } - } - } + addRound(currentPlayerRoundTotal, r, r.getRound1() + r.getRound2()); + addMultipleRounds(currentPlayerRoundTotal, r); } - playerRoundTotals.put(r.getUniqueName(), currentPlayerRoundTotal); } return playerRoundTotals; } + // Helper method to add individual rounds + private void addRound(List totals, RoundScore r, int total) { + totals.add(new RoundTotal(r.getEventId(), r.getLocationId(), r.getTeam(), r.getAthlete(), + r.getClassification(), r.getGender(), total, r.getType())); + } + + // Helper method to add rounds 3 to 8 if applicable + private void addMultipleRounds(List totals, RoundScore r) { + int[] additionalRounds = {r.getRound3() + r.getRound4(), r.getRound5() + r.getRound6(), r.getRound7() + r.getRound8()}; + + for (int round : additionalRounds) { + if (round > 0) { + addRound(totals, r, round); + } else { + break; // Stop processing once a round with zero total is found + } + } + } + public Map> calculatePlayerIndividualTotal(List roundScores, Map> playerRoundTotals) { Map> playerIndividualTotal = new HashMap<>(); @@ -54,8 +68,8 @@ public Map> calculatePlayerIndividualTotal(List playerRoundTotal : playerRoundTotals.values()) { if (playerRoundTotal.isEmpty()) continue; - String playerName = playerRoundTotal.get(0).getUniqueName(); - int roundsToCount = getEventsToCount(playerRoundTotal.get(0).getType()); + String playerName = playerRoundTotal.getFirst().getUniqueName(); + int roundsToCount = getEventsToCount(playerRoundTotal.getFirst().getType()); List indTotal = new ArrayList<>(); // Sort in descending order based on total score @@ -67,7 +81,7 @@ public Map> calculatePlayerIndividualTotal(List indTotal, 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)) { @@ -100,7 +114,7 @@ public Map calculatePlayerFinalTotal(Map(); playerIndividualTotals.forEach((key, totals) -> { if (!totals.isEmpty()) { - var firstTotal = totals.get(0); + var firstTotal = totals.getFirst(); int totalScore = totals.stream().mapToInt(IndividualTotal::getTotal).sum(); playerFinalTotals.put(key, new IndividualTotal( From 893419f9ed7f851574aba6cc51c0021b9482a14d Mon Sep 17 00:00:00 2001 From: Matt Busche Date: Sun, 22 Sep 2024 22:09:29 -0500 Subject: [PATCH 6/6] remove unused import --- src/main/java/trap/report/ReportHelper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/trap/report/ReportHelper.java b/src/main/java/trap/report/ReportHelper.java index 48948bf..8216155 100644 --- a/src/main/java/trap/report/ReportHelper.java +++ b/src/main/java/trap/report/ReportHelper.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; @Service public class ReportHelper {