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
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
📝 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 # 19 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:
nx build upload-lambdafails with TS6059 because the lambda'srootDir: ./srcdoesn't allow compiling files fromlibs/. The build was already failing onmain(the lib had no source files). The fix is to droprootDiror bundle the lambdas with esbuild, which fits better with Dev: Empty Upload Lambda #13.tscwritesdist/**/*.spec.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).lint:checkmatches no files underapps/backend/*/src, so lint currently checks nothing there.