Skip to content

Commit

Permalink
modernize models
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbusche committed Dec 22, 2024
1 parent 43492fc commit 1cffeba
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/main/java/trap/model/IndividualTotal.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public class IndividualTotal {
String type;

public String getTeamForScores() {
return this.type + " " + this.team + " " + this.getTeamClassificationForTotal();
return "%s %s %s".formatted(this.type, this.team, this.getTeamClassification());
}

public String getTeamClassification() {
return this.classification.replace("Senior/Varsity", "Varsity").replace("Senior/Jr. Varsity", "Junior Varsity").replace("Intermediate/Advanced", "Intermediate Advanced").replace("Intermediate/Entry Level", "Intermediate Entry");
return switch (classification) {
case "Senior/Varsity", "Senior/Jr. Varsity", "Junior Varsity" -> "Varsity";
case "Intermediate/Advanced", "Intermediate/Entry Level" -> "Intermediate Entry";
default -> classification;
};
}

public String getTeamClassificationForTotal() {
return this.getTeamClassification().replace("Senior/Jr. Varsity", "Varsity").replace("Senior/Varsity", "Varsity").replace("Junior Varsity", "Varsity").replace("Intermediate Advanced", "Intermediate Entry");
}
}
}
10 changes: 7 additions & 3 deletions src/main/java/trap/model/RoundScore.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public class RoundScore {
String type;

public String getUniqueName() {
return this.getAthlete() + " " + this.getTeam() + " " + this.getClassification() + " " + this.getType();
return String.format("%s %s %s %s", athlete, team, getSimplifiedTeamClassification(), type);
}

public String getTeamClassification() {
return this.classification.replace("Senior/Varsity", "Varsity").replace("Senior/Jr. Varsity", "Junior Varsity").replace("Intermediate/Advanced", "Intermediate Advanced").replace("Intermediate/Entry Level", "Intermediate Entry");
public String getSimplifiedTeamClassification() {
return switch (classification) {
case "Senior/Varsity", "Senior/Jr. Varsity", "Junior Varsity" -> "Varsity";
case "Intermediate/Advanced", "Intermediate/Entry Level" -> "Intermediate Entry";
default -> classification;
};
}
}
4 changes: 2 additions & 2 deletions src/main/java/trap/model/RoundTotal.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public class RoundTotal {
String type;

public String getUniqueName() {
return this.getAthlete() + " " + this.getTeam() + " " + this.getClassification() + " " + this.getType();
return String.format("%s %s %s %s", athlete, team, classification, type);
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/trap/report/ReportHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private void populateTeamData(Sheet sheet, String teamType, CellStyle mainTextSt
int startColumn = 1;
long start = System.currentTimeMillis();

List<Map.Entry<String, ArrayList<IndividualTotal>>> teamData = teamScoresByTotal.entrySet().stream().filter(f -> f.getValue().getFirst().getTeamClassificationForTotal().equals(teamType) && f.getValue().getFirst().getType().equals(SINGLES)).toList();
List<Map.Entry<String, ArrayList<IndividualTotal>>> teamData = teamScoresByTotal.entrySet().stream().filter(f -> f.getValue().getFirst().getTeamClassification().equals(teamType) && f.getValue().getFirst().getType().equals(SINGLES)).toList();
List<TeamScore> teamScores = getTeamScores(teamData);
logger.info("Ran query for singles by {} in {} ms", teamType, System.currentTimeMillis() - start);
for (var teamScore : teamScores) {
Expand All @@ -238,7 +238,7 @@ private void populateTeamData(Sheet sheet, String teamType, CellStyle mainTextSt
for (var type : types) {
updateRow = rows;
start = System.currentTimeMillis();
teamData = teamScoresByTotal.entrySet().stream().filter(f -> f.getValue().getFirst().getTeamClassificationForTotal().equals(teamType) && f.getValue().getFirst().getType().equals(type)).toList();
teamData = teamScoresByTotal.entrySet().stream().filter(f -> f.getValue().getFirst().getTeamClassification().equals(teamType) && f.getValue().getFirst().getType().equals(type)).toList();
teamScores = getTeamScores(teamData);
logger.info("Ran query for {} by {} in {} ms", type, teamType, System.currentTimeMillis() - start);
for (var teamScore : teamScores) {
Expand Down

0 comments on commit 1cffeba

Please sign in to comment.