Skip to content

Commit 9a8141a

Browse files
committed
have draft picks be in their respective season; fetch next year's draft picks from the next season
1 parent ac1d25e commit 9a8141a

9 files changed

Lines changed: 44 additions & 163 deletions

File tree

observablehq.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import stripBom from "strip-bom";
55

66
// Read seasons at config-load time so they can be inlined into every page's HTML
77
const _seasonsRaw = csvParse(stripBom(readFileSync("src/data/static/seasons.csv", "utf-8")));
8-
const _seasons = _seasonsRaw.map(s => s.season);
8+
const _seasons = _seasonsRaw.filter(s => s.stub !== "true").map(s => s.season);
99
const _currentSeason = _seasonsRaw.find(s => s.current === "true")?.season || _seasons[_seasons.length - 1];
1010
export default {
1111
// The app’s title; used in the sidebar and webpage titles.

src/components/loadfiles.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ export async function loadSeasonData(season) {
210210

211211
// Load available seasons from config
212212
export const seasonsConfig = await readCsvFile("src/data/static/seasons.csv");
213-
export const seasons = seasonsConfig.map(s => s.season);
213+
export const allSeasons = seasonsConfig.map(s => s.season);
214+
export const seasons = seasonsConfig.filter(s => s.stub !== 'true').map(s => s.season);
214215
export const currentSeason = seasonsConfig.find(s => s.current === "true")?.season || seasons[seasons.length - 1];
215216

216217
// Backward-compatible top-level exports pointing to current season data

src/data/draftOrder.json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const allData = {};
6969
for (const season of seasons) {
7070
const sf = await loadSeasonData(season);
7171
const draftOrderData = await readCsvFile(`${sf.basePath}/draft_order.csv`);
72-
const currentPicks = await readCsvFile(`${sf.basePath}/current_picks.csv`);
72+
const currentPicks = await readCsvFile(`${sf.basePath}/draft_picks.csv`);
7373
const teamInfo = await readCsvFile(`${sf.basePath}/team_info.csv`);
7474
allData[season] = buildSeasonDraftOrder(sf, draftOrderData, currentPicks, teamInfo);
7575
}

src/data/static/2025-26/current_picks.csv

Lines changed: 0 additions & 129 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ MTL4,OTT
113113
NJD4,NJD
114114
NSH4,NSH
115115
NYI4,NYI
116-
NYR4,NYR
116+
NYR4,WPG
117117
OTT4,OTT
118118
PHI4,BUF
119119
PIT4,STL
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,5 @@ TOR4,WPG
125125
UTA4,UTA
126126
VAN4,VAN
127127
VEG4,VEG
128-
WPG4,WPG
128+
WPG4,NYR
129129
WSH4,DAL
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CGY1,CGY
88
CHI1,CHI
99
COL1,COL
1010
DAL1,DAL
11-
DET1,WSH
11+
DET1,DET
1212
EDM1,EDM
1313
FLA1,FLA
1414
LAK1,LAK
@@ -24,8 +24,8 @@ PIT1,PIT
2424
SEA1,SEA
2525
SJS1,SJS
2626
STL1,STL
27-
TBL1,SEA
28-
TOR1,PIT
27+
TBL1,TBL
28+
TOR1,TOR
2929
UTA1,UTA
3030
VAN1,VAN
3131
VEG1,VEG
@@ -40,33 +40,33 @@ CGY2,CGY
4040
CHI2,CHI
4141
COL2,COL
4242
DAL2,DAL
43-
DET2,WSH
43+
DET2,DET
4444
EDM2,EDM
4545
FLA2,FLA
4646
LAK2,LAK
4747
MIN2,MIN
4848
MTL2,MTL
4949
NJD2,NJD
5050
NSH2,NSH
51-
NYI2,DAL
51+
NYI2,NYI
5252
NYR2,NYR
5353
OTT2,OTT
54-
PHI2,CHI
54+
PHI2,PHI
5555
PIT2,PIT
5656
SEA2,SEA
5757
SJS2,SJS
5858
STL2,STL
59-
TBL2,DAL
60-
TOR2,WPG
59+
TBL2,TBL
60+
TOR2,TOR
6161
UTA2,UTA
6262
VAN2,VAN
6363
VEG2,VEG
64-
WPG2,ANA
64+
WPG2,WPG
6565
WSH2,WSH
6666
ANA3,ANA
6767
BOS3,BOS
6868
BUF3,BUF
69-
CAR3,CHI
69+
CAR3,CAR
7070
CBJ3,CBJ
7171
CGY3,CGY
7272
CHI3,CHI
@@ -81,21 +81,21 @@ MTL3,MTL
8181
NJD3,NJD
8282
NSH3,NSH
8383
NYI3,NYI
84-
NYR3,DAL
84+
NYR3,NYR
8585
OTT3,OTT
86-
PHI3,CAR
86+
PHI3,PHI
8787
PIT3,PIT
8888
SEA3,SEA
89-
SJS3,TOR
89+
SJS3,SJS
9090
STL3,STL
9191
TBL3,TBL
92-
TOR3,DAL
92+
TOR3,TOR
9393
UTA3,UTA
9494
VAN3,VAN
9595
VEG3,VEG
9696
WPG3,WPG
9797
WSH3,WSH
98-
ANA4,DAL
98+
ANA4,ANA
9999
BOS4,BOS
100100
BUF4,BUF
101101
CAR4,CAR
@@ -109,21 +109,21 @@ EDM4,EDM
109109
FLA4,FLA
110110
LAK4,LAK
111111
MIN4,MIN
112-
MTL4,DET
112+
MTL4,MTL
113113
NJD4,NJD
114114
NSH4,NSH
115115
NYI4,NYI
116-
NYR4,DAL
116+
NYR4,NYR
117117
OTT4,OTT
118-
PHI4,CBJ
119-
PIT4,ANA
118+
PHI4,PHI
119+
PIT4,PIT
120120
SEA4,SEA
121-
SJS4,MTL
121+
SJS4,SJS
122122
STL4,STL
123-
TBL4,MTL
124-
TOR4,WPG
123+
TBL4,TBL
124+
TOR4,TOR
125125
UTA4,UTA
126126
VAN4,VAN
127127
VEG4,VEG
128128
WPG4,WPG
129-
WSH4,DAL
129+
WSH4,WSH

src/data/static/seasons.csv

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
season,label,ageCutoff,current
2-
2025-26,2025-26,2025-09-15,false
3-
2026-27,2026-27,2026-09-15,true
1+
season,label,ageCutoff,current,stub
2+
2025-26,2025-26,2025-09-15,false,false
3+
2026-27,2026-27,2026-09-15,true,false
4+
2027-28,2027-28,2027-09-15,false,true

src/data/teamInfo.json.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readCsvFile, seasons, currentSeason, loadSeasonData, mapPosition, calculateAge } from "../components/loadfiles.js";
1+
import { readCsvFile, seasons, allSeasons, currentSeason, loadSeasonData, mapPosition, calculateAge } from "../components/loadfiles.js";
22

33
function buildSeasonTeamInfo(sf, teamInfo, teamCash, owners, playerInfo, contracts, currentPicks, nextPicks) {
44
const { rosterPeriods, availablePeriods, lastPeriodNum } = sf;
@@ -74,8 +74,16 @@ for (const season of seasons) {
7474
const owners = await readCsvFile(`${sf.basePath}/owners.csv`);
7575
const playerInfo = await readCsvFile(`${sf.basePath}/player_info.csv`);
7676
const contracts = await readCsvFile(`${sf.basePath}/contracts.csv`);
77-
const currentPicks = await readCsvFile(`${sf.basePath}/current_picks.csv`);
78-
const nextPicks = await readCsvFile(`${sf.basePath}/next_picks.csv`);
77+
const currentPicks = await readCsvFile(`${sf.basePath}/draft_picks.csv`);
78+
const nextSeasonIndex = allSeasons.indexOf(season) + 1;
79+
let nextPicks = [];
80+
if (nextSeasonIndex < allSeasons.length) {
81+
try {
82+
nextPicks = await readCsvFile(`src/data/static/${allSeasons[nextSeasonIndex]}/draft_picks.csv`);
83+
} catch (e) {
84+
nextPicks = [];
85+
}
86+
}
7987
allData[season] = buildSeasonTeamInfo(sf, teamInfo, teamCash, owners, playerInfo, contracts, currentPicks, nextPicks);
8088
}
8189

0 commit comments

Comments
 (0)