Repository navigation
Conversation
naman0r
marked this pull request as ready for review
October 8, 2026 18:28
naman0r
marked this pull request as draft
October 8, 2026 18:28
naman0r
force-pushed
the
10-historical-parser
branch
from
October 8, 2026 18:30
0cc0438 to
f50c478
Compare
Map @bho/weather-parsing in tsconfig.base.json so the lambdas resolve the library from source; nothing installs the file: dependency today.
parseHistorical reads the All Daily Records CSV and returns one record per day, or every row error in the file. The fixture is the synthetic test sheet exported from Drive.
naman0r
force-pushed
the
10-historical-parser
branch
from
October 10, 2026 21:57
f50c478 to
eb677d2
Compare
naman0r
marked this pull request as ready for review
October 13, 2026 21:41
Rayna-Yu
approved these changes
Oct 15, 2026
Rayna-Yu
left a comment
Collaborator
There was a problem hiding this comment.
Looks good! Nice work, and thanks for flagging the TS6059 break!
After you merge, I'll apply the fixes you outlined and remove rootDir from the upload-lambda tsconfig and ignore dist/ in its Jest config directly on main. (If you have the capacity it would be great if you could do it on this branch, but either way works just lmk!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ℹ️ Issue
Closes #10
historical sheet: https://docs.google.com/spreadsheets/d/1WI8CxTJ7edRajo3JHZX0WmTklvCqRy5x/edit?rtpof=true&sd=true
📝 Description
Adds a parser for the historical records spreadsheet (the
All Daily Recordstab). The upload lambda can call it to check a file before anything is written todaily_records. It returns either one record per day or a list of every problem in the file, each with the sheet row and column, so staff can fix everything in one pass. The error list matches the shape ofimports.errors.Briefly list the changes made to the code:
Added
parseHistorical(csv)inapps/backend/upload-lambda/src/parsers/historical.ts. It finds the header row even when rows sit above it (the Drive export has a link and a blank row first), looks up columns by header name, and checks that:Precip and snow stay strings ("5.30"), matching how
pgreadsnumeric.Source textis not stored, since it repeats the other columns.Added shared types in
libs/weather-parsing/src/types.ts:ParseResult<T>,RowError, andHistoricalRecord.HistoricalRecorduses thedaily_recordscolumn names, so a parsed row plusstationIdandimportIdcan go straight into an insert. The daily parser (Dev: Build a CSV parsing utility - Daily hourly-log parser #9) can reuseParseResultandRowError.Added a small CSV reader in
parsers/csv.ts(no new dependency). It handles quoted fields, which year lists like"2014, 1977"need. Dev: Build a CSV parsing utility - Daily hourly-log parser #9 can use it too.Mapped
@bho/weather-parsingintsconfig.base.json. The lambdas list it as afile:dependency, but nothing installs it, so the import didn't resolve before.✔️ Verification
Unit tests cover the CSV reader and the parser. The parser tests use the synthetic test sheet, exported from Drive as
parsers/__fixtures__/historical.csv(366 rows, every field of Jan 1 checked), plus small sheets for each rule above.yarn install npx jest apps/backend/upload-lambda # 20 testsTo run the parser on any exported CSV and print the rows or the errors:
No UI changes.
🏕️ (Optional) Future Work / Notes
Open questions for the team (current behavior in parentheses):
T) for precip or snow? (Rejected.)Found along the way:
tsc, and itsrootDir: ./srconly allows files undersrc/. The parser now imports types fromlibs/weather-parsing/src, sotscinapps/backend/upload-lambdastops with error TS6059. Onmainthat command passes. CI doesn't build the backend, so the checks stay green.rootDirline fromapps/backend/upload-lambda/tsconfig.json. Compiled files then go todist/apps/backend/upload-lambda/src/instead ofdist/; nothing readsdistyet. Bundling the lambdas with esbuild in Dev: Empty Upload Lambda #13 would also fix it.nx build upload-lambdaalready failed onmain, for a different reason: it builds the lib first, and the lib had no source files.tscwritesdist/**/*.test.jseven when it errors, and rootjestthen runs those copies. Addingdistto jest's ignore paths would stop that.strictNullChecks, so!result.okdoesn't narrow aParseResult. Useresult.ok === false(noted on the type).yarn lint:checkmatches no files underapps/backend/*/src. CI runsnx affected -t lintinstead, which has lintedupload-lambdasince Dev: Empty Upload Lambda #22.