Skip to content

Commit 0ccb5a6

Browse files
committed
Added HTML prize list, and test for mass-start runner finishing before the runner in the previous leg.
1 parent 3fc2a71 commit 0ccb5a6

14 files changed

+181
-6
lines changed

src/main/java/lap_race/OutputHTML.java

+44-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.nio.charset.StandardCharsets;
99
import java.nio.file.Files;
1010
import java.nio.file.Path;
11+
import java.util.List;
1112

1213
public class OutputHTML extends Output {
1314

@@ -16,9 +17,13 @@ public OutputHTML(final Results results) {
1617
}
1718

1819
@Override
19-
public void printPrizes() {
20+
public void printPrizes() throws IOException {
2021

21-
throw new UnsupportedOperationException();
22+
final OutputStream stream = Files.newOutputStream(output_directory_path.resolve(prizes_filename + ".html"));
23+
24+
try (final OutputStreamWriter html_writer = new OutputStreamWriter(stream)) {
25+
printPrizes(html_writer);
26+
}
2227
}
2328

2429
@Override
@@ -58,6 +63,11 @@ public void printCombined() throws IOException {
5863

5964
html_writer.append("""
6065
<h3><strong>Results</strong></h3>
66+
""");
67+
68+
printPrizes(html_writer);
69+
70+
html_writer.append("""
6171
<h4>Overall</h4>
6272
""");
6373

@@ -81,6 +91,38 @@ public void printCombined() throws IOException {
8191
}
8292
}
8393

94+
private void printPrizes(OutputStreamWriter html_writer) throws IOException {
95+
96+
html_writer.append("<h4>Prizes</h4>\n");
97+
98+
for (final Category category : CATEGORY_REPORT_ORDER)
99+
printPrizes(category, html_writer);
100+
}
101+
102+
private void printPrizes(final Category category, final OutputStreamWriter writer) throws IOException {
103+
104+
writer.append("<p><strong>").append(String.valueOf(category)).append("</strong></p>\n");
105+
writer.append("<ol>\n");
106+
107+
final List<Team> category_prize_winners = results.prize_winners.get(category);
108+
109+
if (category_prize_winners.isEmpty())
110+
writer.append("No results\n");
111+
112+
int position = 1;
113+
for (final Team team : category_prize_winners) {
114+
115+
final OverallResult result = results.overall_results[results.findIndexOfTeamWithBibNumber(team.bib_number)];
116+
117+
writer.append("<li>").
118+
append(result.team.name).append(" (").
119+
append(result.team.category.toString()).append(") ").
120+
append(format(result.duration())).append("</li>\n");
121+
}
122+
123+
writer.append("</ol>\n\n");
124+
}
125+
84126
private void printOverallResults(OutputStreamWriter html_writer) throws IOException {
85127

86128
printOverallResultsHeader(html_writer);

src/main/java/lap_race/Results.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ private void fillLegFinishTimes() {
295295

296296
final OverallResult result = overall_results[findIndexOfTeamWithBibNumber(bib_number)];
297297

298-
LegResult temp = result.leg_results[leg_index - 1];
299-
result.leg_results[leg_index - 1] = result.leg_results[leg_index];
300-
result.leg_results[leg_index] = temp;
298+
final Duration temp = result.leg_results[leg_index - 1].finish_time;
299+
result.leg_results[leg_index - 1].finish_time = result.leg_results[leg_index].finish_time;
300+
result.leg_results[leg_index].finish_time = temp;
301301
}
302302
}
303303
}
@@ -459,6 +459,7 @@ private void printPrizes() throws IOException {
459459

460460
output_text.printPrizes();
461461
output_PDF.printPrizes();
462+
output_HTML.printPrizes();
462463
}
463464

464465
private void printCombined() throws IOException {

src/test/java/lap_race/devils_burdens/ResultsTest.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ public void massStart_4_AllCompleted() throws Exception {
226226
processingCompletes("mass_start_4/all_completed");
227227
}
228228

229+
@Test
230+
public void massStart_4_LegsSwapped() throws Exception {
231+
232+
processingCompletes("mass_start_4/legs_swapped");
233+
}
234+
229235
@Test
230236
public void massStart_4_DNFLeg1() throws Exception {
231237

@@ -460,7 +466,7 @@ private void configureTest(String test_resource_root) throws IOException {
460466
// Swap these when debugging and you don't want the test results to be immediately deleted.
461467

462468
temp_directory = Files.createTempDirectory(null);
463-
// temp_directory = Paths.get("/Users/gnck/Desktop/temp");
469+
//temp_directory = Paths.get("/Users/gnck/Desktop/temp");
464470

465471
Path temp_input_sub_directory = Files.createDirectories(temp_directory.resolve("input"));
466472
temp_output_sub_directory = Files.createDirectories(temp_directory.resolve("output"));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Pos,No,Team,Category,Runners 1,Leg 1,Split 1,Runners 2,Leg 2,Split 2,Runners 3,Leg 3,Split 3,Runners 4,Leg 4,Total
2+
1,1,Team 1,Women Senior,John Smith,00:42:43,00:42:43,Hailey Dickson:) & Alix Crawford,00:44:17,01:27:00,Rhys Müllar & Paige Thompson,01:08:05,02:35:05,Amé MacDonald,01:12:53,03:47:58
3+
2,2,Team 2,Open 50+,Bartosz Thomson,00:43:52,00:43:52,John Smith & Zuzanna Miller-Ford,00:59:16,01:43:08,Leo McKenzie & Henry Muir,00:52:26,02:35:34,Regan Millar,01:12:55,03:48:29
4+
3,4,Team 4,Women 50+,Sofia O'Connor,00:45:35,00:45:35,Philip O’Donohue & Hasan Robertson,01:01:48,01:47:23,Lena K. Maclean & Isabel Ritchie,02:02:29,03:49:52,Martha Gibson (M4),00:00:10,03:50:02
5+
4,5,Team 5,Open Senior,Clark O' Connor,00:45:43,00:45:43,Nina Joan Fiona Walker & Hope Christie,01:02:01,01:47:44,Cayla Duncan & Scott Kelly,00:49:35,02:37:19,Amelia Muir (M4),01:13:21,03:50:40
6+
5,3,Team 3,Open Senior,JackBruce,00:44:59,00:44:59,Martin King & Leland Donaldson,00:58:49,01:43:48,Neil MacDonald & Myles Christie,00:52:11,02:35:59,Hubert Gray,01:24:01,04:00:00
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Pos,Runner,Time
2+
1,John Smith,00:42:43
3+
2,Bartosz Thomson,00:43:52
4+
3,JackBruce,00:44:59
5+
4,Sofia O'Connor,00:45:35
6+
5,Clark O' Connor,00:45:43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Pos,Runners,Time
2+
1,Hailey Dickson:) & Alix Crawford,00:44:17
3+
2,Martin King & Leland Donaldson,00:58:49
4+
3,John Smith & Zuzanna Miller-Ford,00:59:16
5+
4,Philip O’Donohue & Hasan Robertson,01:01:48
6+
5,Nina Joan Fiona Walker & Hope Christie,01:02:01
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Pos,Runners,Time
2+
1,Cayla Duncan & Scott Kelly,00:49:35
3+
2,Neil MacDonald & Myles Christie,00:52:11
4+
3,Leo McKenzie & Henry Muir,00:52:26
5+
4,Rhys Müllar & Paige Thompson,01:08:05
6+
5,Lena K. Maclean & Isabel Ritchie,02:02:29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Pos,Runner,Time
2+
1,Martha Gibson,00:00:10
3+
2,Amé MacDonald,01:12:53
4+
3,Regan Millar,01:12:55
5+
4,Amelia Muir,01:13:21
6+
5,Hubert Gray,01:24:01
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Pos,No,Team,Category,Total
2+
1,1,Team 1,Women Senior,03:47:58
3+
2,2,Team 2,Open 50+,03:48:29
4+
3,4,Team 4,Women 50+,03:50:02
5+
4,5,Team 5,Open Senior,03:50:40
6+
5,3,Team 3,Open Senior,04:00:00
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Devil's Burdens Results 2020
2+
============================
3+
4+
Category: Women Senior
5+
----------------------
6+
7+
1: Team 4 (Women 50+) 03:50:02
8+
9+
10+
Category: Open Senior
11+
---------------------
12+
13+
1: Team 1 (Women Senior) 03:47:58
14+
2: Team 5 (Open Senior) 03:50:40
15+
3: Team 3 (Open Senior) 04:00:00
16+
17+
18+
Category: Women 40+
19+
-------------------
20+
21+
No results
22+
23+
24+
Category: Open 40+
25+
------------------
26+
27+
1: Team 2 (Open 50+) 03:48:29
28+
29+
30+
Category: Women 50+
31+
-------------------
32+
33+
No results
34+
35+
36+
Category: Open 50+
37+
------------------
38+
39+
No results
40+
41+
42+
Category: Women 60+
43+
-------------------
44+
45+
No results
46+
47+
48+
Category: Open 60+
49+
------------------
50+
51+
No results
52+
53+
54+
Category: Mixed Senior
55+
----------------------
56+
57+
No results
58+
59+
60+
Category: Mixed 40+
61+
-------------------
62+
63+
No results
64+
65+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1 Team 1 Women Senior John Smith Hailey Dickson:) & Alix Crawford Rhys Müllar & Paige Thompson Amé MacDonald
2+
2 Team 2 Open 50+ Bartosz Thomson John Smith & Zuzanna Miller-Ford Leo McKenzie & Henry Muir Regan Millar
3+
3 Team 3 Open Senior JackBruce Martin King & Leland Donaldson Neil MacDonald & Myles Christie Hubert Gray
4+
4 Team 4 Women 50+ Sofia O'Connor Philip O’Donohue & Hasan Robertson Lena K. Maclean & Isabel Ritchie Martha Gibson
5+
5 Team 5 Open Senior Clark O' Connor Nina Joan Fiona Walker & Hope Christie Cayla Duncan & Scott Kelly Amelia Muir

src/test/resources/devils_burdens/mass_start_4/legs_swapped/input/rawtimes.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1 42:432 43:523 44:594 45:355 45:431 1:27:002 1:43:083 1:43:484 1:47:235 1:47:441 2:35:052 2:35:343 2:35:594 2:36:105 2:37:191 3:47:582 3:48:295 3:49:214 3:49:523 4:0:0
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ENTRIES_FILENAME = entries.txt
2+
RAW_RESULTS_FILENAME = rawtimes.txt
3+
YEAR = 2020
4+
NUMBER_OF_LEGS = 4
5+
PAIRED_LEGS = 2,3
6+
RACE_NAME_FOR_RESULTS = Devil's Burdens
7+
RACE_NAME_FOR_FILENAMES = simple
8+
9+
# Elapsed duration from start of leg 1 to mass start time for each leg.
10+
# 23:59:59 indicates no mass start.
11+
MASS_START_ELAPSED_TIMES = 23:59:59,23:59:59,23:59:59,2:36:00
12+
13+
# Comma-separated sequence of bib-number/leg-number for all legs that have a time
14+
# recorded but the runners DNF'd the leg.
15+
DNF_LEGS =
16+
17+
# Comma-separated sequence bib-number/leg-number for all legs where the runner finished
18+
# before the runner on the previous leg.
19+
LEG_TIME_SWAPS = 4/4

0 commit comments

Comments
 (0)