Repository navigation
Add zip / zipcode analysis inputs to reports and data - #61
Merged
Merged
Conversation
ejanalysis
marked this pull request as ready for review
October 14, 2026 21:02
Updated the 'report' parameter description for clarity.
ejanalysis
commented
Oct 15, 2026
ejanalysis
left a comment
Contributor
Author
There was a problem hiding this comment.
The changes look good and pass tests, but we will try it out in the API run locally as well.
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core request-routing behavior for multiple API endpoints and depends on external EJAM/ZCTA behavior that can’t be fully validated here.
2 open findings
What changed in this PR
Adds first-class ZIP/ZCTA support to the EJAM-API analysis endpoints so callers can request /report and /data by zip/zipcode (aliases) in addition to existing location inputs, with normalization/validation and updated documentation/CI coverage.
Changes:
- Add
zip/zipcodeparsing, normalization, and conflict validation, and wire ZIP inputs into EJAM analysis for GET/POST/reportand POST/data. - Preserve analyzed ZIP identity in
/dataoutputs (including after missing-ZCTA drops) and support ZIP geometries. - Add route-contract tests + a dedicated GitHub Actions workflow, and document ZIP/ZCTA usage in the README.
| File | Description |
|---|---|
rest_controller.r |
Implements ZIP input normalization/validation and integrates ZIP routing into /report and /data, including ZIP identity preservation and geometry handling. |
tests/test-zip-api.R |
Adds contract-style tests for ZIP normalization, validation failures, route behavior, and OpenAPI param exposure (when deps are present). |
README.md |
Documents new ZIP/ZCTA request patterns, normalization rules, and examples for /report and /data. |
.github/workflows/test-zip-api.yaml |
Adds CI workflow to run the ZIP contract tests and existing query pagination assertions. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.


ZIP codes cannot currently be passed directly to the API, despite EJAM v3.2022.3 supporting
ejamit(zipcode=). Addzipandzipcodeto GET/POST/reportand POST/data, using ZCTA boundaries with a zero buffer by default./report?zip=20912requests a single-site report;/report?zipcode=20912,10605&sitenumber=0requests the aggregate report.Accept comma lists and JSON arrays; normalize leading zeroes/ZIP+4 and remove duplicates. Invalid/conflicting ZIP inputs return HTTP 400. Multi-ZIP report selection beyond the matched ZCTAs also returns 400 instead of silently falling back to a different ZIP; one-ZIP per-site URLs retain their original row labels. ZIP data rows include
zipcodefor the ZIP actually analyzed, preserving identity when postal ZIPs without ZCTAs are dropped. Geometry output uses the same codes and row order. FIPS remains separate:fips=10001means Kent County, Delaware. Document first-download caching, missing ZCTAs, and examples.Validation at
de27a1c:zip=10001data identifies New York (population 24,203), whilefips=10001with county scale identifies Delaware (population 182,400).Implements Public-Environmental-Data-Partners/EJAM#662. Companion Public-Environmental-Data-Partners/EJAM#663 adds both aliases to R API wrappers, URL parsing and result report links, and copies this exact API controller. Merge the API PR first, refresh the companion mirror provenance to merged API
main, then merge EJAM. Shiny ZIP entry and API handoff remain in EJAM#486; broader non-API helpers are tracked in EJAM#664. Hosted availability requires a separate deployment.