Skip to content

Commit adb456a

Browse files
committed
Add draft order to the dashboard
1 parent d37059e commit adb456a

3 files changed

Lines changed: 166 additions & 0 deletions

File tree

src/Teams.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ toc: false
88
```js
99
// Load the data files
1010
const teamInfo = await FileAttachment("./data/teamInfo.json").json();
11+
const draftOrder = await FileAttachment("./data/draftOrder.json").json();
1112
const currentPeriod = teamInfo.availablePeriods.length;
1213
```
1314
<div class="tabs">
1415
<div class="tab-buttons">
1516
<button class="tab-button active" onclick="showTab('cash-tab', this)">Team Cash Balances</button>
1617
<button class="tab-button" onclick="showTab('picks-tab', this)">Team Draft Picks</button>
18+
<button class="tab-button" onclick="showTab('draft-order-tab', this)">Draft Order</button>
1719
<button class="tab-button" onclick="showTab('owner-tab', this)">Team Owners</button>
1820
</div>
1921

@@ -91,6 +93,44 @@ const currentPeriod = teamInfo.availablePeriods.length;
9193
})}
9294
</div>
9395

96+
<div id="draft-order-tab" class="tab-content">
97+
<h3>Round 1 Draft Order</h3>
98+
${Inputs.table(draftOrder.round1, {
99+
columns: ["order", "pick", "pickName", "owner", "ownerName"],
100+
header: {
101+
order: "Pick #",
102+
pick: "Original Team",
103+
pickName: "Team Name",
104+
owner: "Held By",
105+
ownerName: "Holder Name"
106+
},
107+
width: {
108+
order: 70,
109+
pick: 80,
110+
owner: 100
111+
},
112+
rows: 32,
113+
select: false
114+
})}
115+
<h3>Rounds 2–4 Draft Order</h3>
116+
${Inputs.table(draftOrder.otherRounds, {
117+
columns: ["order", "pick", "pickName", ...draftOrder.otherRoundNumbers.map(r => `r${r}`), ...draftOrder.otherRoundNumbers.map(r => `r${r}Name`)],
118+
header: {
119+
order: "Pick #",
120+
pick: "Original Team",
121+
pickName: "Team Name",
122+
...Object.fromEntries(draftOrder.otherRoundNumbers.map(r => [`r${r}`, `R${r} Held By`])),
123+
...Object.fromEntries(draftOrder.otherRoundNumbers.map(r => [`r${r}Name`, `R${r} Holder`]))
124+
},
125+
width: {
126+
order: 70,
127+
pick: 80
128+
},
129+
rows: 32,
130+
select: false
131+
})}
132+
</div>
133+
94134
<div id="owner-tab" class="tab-content">
95135
${Inputs.table(teamInfo.teams, {
96136
columns: [

src/data/draftOrder.json.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import {readCsvFile} from "../components/loadfiles.js";
2+
3+
const draftOrder = await readCsvFile("src/data/static/draft_order.csv");
4+
const currentPicks = await readCsvFile("src/data/static/current_picks.csv");
5+
const teamInfo = await readCsvFile("src/data/static/team_info.csv");
6+
7+
// Build a lookup map: pick key (e.g. "ANA1") -> owner
8+
const pickOwnerMap = {};
9+
for (const pick of currentPicks) {
10+
pickOwnerMap[pick.PICK] = pick.OWNER;
11+
}
12+
13+
// Build a lookup map: ABBR -> NAME
14+
const teamNameMap = {};
15+
for (const team of teamInfo) {
16+
teamNameMap[team.ABBR] = team.NAME;
17+
}
18+
19+
// Determine which rounds beyond 1 exist in current_picks
20+
const roundsInPicks = [...new Set(currentPicks.map(p => {
21+
const match = p.PICK.match(/\d+$/);
22+
return match ? parseInt(match[0]) : null;
23+
}).filter(Boolean))].sort((a, b) => a - b);
24+
25+
const otherRounds = roundsInPicks.filter(r => r > 1);
26+
27+
// Round 1 order
28+
const round1Rows = draftOrder
29+
.filter(row => row.ROUND === "1")
30+
.sort((a, b) => +a.ORDER - +b.ORDER)
31+
.map(row => ({
32+
order: +row.ORDER,
33+
pick: row.TEAM,
34+
pickName: teamNameMap[row.TEAM] || row.TEAM,
35+
owner: pickOwnerMap[`${row.TEAM}1`] || "—",
36+
ownerName: teamNameMap[pickOwnerMap[`${row.TEAM}1`]] || "—"
37+
}));
38+
39+
// Other rounds order (ROUND=2 rows define the order for all rounds 2+)
40+
const otherRoundsRows = draftOrder
41+
.filter(row => row.ROUND === "2")
42+
.sort((a, b) => +a.ORDER - +b.ORDER)
43+
.map(row => {
44+
const entry = {
45+
order: +row.ORDER,
46+
pick: row.TEAM,
47+
pickName: teamNameMap[row.TEAM] || row.TEAM
48+
};
49+
for (const r of otherRounds) {
50+
const owner = pickOwnerMap[`${row.TEAM}${r}`] || "—";
51+
entry[`r${r}`] = owner;
52+
entry[`r${r}Name`] = teamNameMap[owner] || "—";
53+
}
54+
return entry;
55+
});
56+
57+
process.stdout.write(JSON.stringify({
58+
round1: round1Rows,
59+
otherRounds: otherRoundsRows,
60+
otherRoundNumbers: otherRounds
61+
}));

src/data/static/draft_order.csv

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
ORDER,TEAM,ROUND
2+
1,EDM,1
3+
2,PIT,1
4+
3,VAN,1
5+
4,MTL,1
6+
5,LAK,1
7+
6,CBJ,1
8+
7,CHI,1
9+
8,NSH,1
10+
9,BOS,1
11+
10,SEA,1
12+
11,COL,1
13+
12,DAL,1
14+
13,OTT,1
15+
14,WSH,1
16+
15,FLA,1
17+
16,NYI,1
18+
17,TOR,1
19+
18,STL,1
20+
19,ANA,1
21+
20,CAR,1
22+
21,TBL,1
23+
22,VEG,1
24+
23,NJD,1
25+
24,UTA,1
26+
25,CGY,1
27+
26,BUF,1
28+
27,WPG,1
29+
28,SJS,1
30+
29,MIN,1
31+
30,PHI,1
32+
31,NYR,1
33+
32,DET,1
34+
1,VAN,2
35+
2,PIT,2
36+
3,MTL,2
37+
4,LAK,2
38+
5,CBJ,2
39+
6,CHI,2
40+
7,EDM,2
41+
8,NSH,2
42+
9,BOS,2
43+
10,SEA,2
44+
11,COL,2
45+
12,DAL,2
46+
13,OTT,2
47+
14,WSH,2
48+
15,FLA,2
49+
16,NYI,2
50+
17,TOR,2
51+
18,STL,2
52+
19,ANA,2
53+
20,CAR,2
54+
21,TBL,2
55+
22,VEG,2
56+
23,NJD,2
57+
24,UTA,2
58+
25,CGY,2
59+
26,BUF,2
60+
27,WPG,2
61+
28,SJS,2
62+
29,MIN,2
63+
30,PHI,2
64+
31,NYR,2
65+
32,DET,2

0 commit comments

Comments
 (0)