Skip to content

Commit 11c6530

Browse files
committed
Handle case where there are no performance scores yet
1 parent 652f904 commit 11c6530

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/main/java/fll/web/report/AwardSummarySheet.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,16 @@ private Document generateReport(final Connection connection,
173173
for (AwardCategory category : AwardDeterminationOrder.get(connection, challengeDescription)) {
174174
switch (category) {
175175
case PerformanceScoreCategory awardCategory -> {
176-
final Element performance = createPerformanceBlock(document, connection, challengeDescription, tournament,
177-
groupName, category);
178-
if (!first) {
179-
report.appendChild(FOPUtils.createHorizontalLineBlock(document, SEPARATOR_THICKNESS));
180-
} else {
181-
first = false;
176+
final @Nullable Element performance = createPerformanceBlock(document, connection, challengeDescription,
177+
tournament, groupName, category);
178+
if (null != performance) {
179+
if (!first) {
180+
report.appendChild(FOPUtils.createHorizontalLineBlock(document, SEPARATOR_THICKNESS));
181+
} else {
182+
first = false;
183+
}
184+
report.appendChild(performance);
182185
}
183-
report.appendChild(performance);
184186
}
185187
case NonNumericCategory awardCategory -> {
186188
if (!CategoriesIgnored.isNonNumericCategoryIgnored(connection, tournament.getLevel(), awardCategory)) {
@@ -280,12 +282,12 @@ private Element createChampionsBlock(final Document document) {
280282
return section;
281283
}
282284

283-
private Element createPerformanceBlock(final Document document,
284-
final Connection connection,
285-
final ChallengeDescription description,
286-
final Tournament tournament,
287-
final String groupName,
288-
final AwardCategory awardCategory)
285+
private @Nullable Element createPerformanceBlock(final Document document,
286+
final Connection connection,
287+
final ChallengeDescription description,
288+
final Tournament tournament,
289+
final String groupName,
290+
final AwardCategory awardCategory)
289291
throws SQLException {
290292
final Map<Integer, TournamentTeam> tournamentTeams = Queries.getTournamentTeams(connection,
291293
tournament.getTournamentID());
@@ -326,6 +328,10 @@ private Element createPerformanceBlock(final Document document,
326328
groupName));
327329
}
328330

331+
if (scores.isEmpty()) {
332+
return null;
333+
}
334+
329335
for (final Top10.ScoreEntry entry : scores) {
330336
if (entry.getRank() > NUM_PERFORMANCE_FINALISTS) {
331337
break;

0 commit comments

Comments
 (0)