Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modernize models #463

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading