feat(api): resolve match construction period by year - #31
Merged
Merged
Conversation
GET /api/v1/variants/{cc}/match now accepts a construction year as an
alternative to the TABULA period code. Callers holding a build year no
longer hardcode each country's period-year bands: exactly one of period
or year is required, and ignis maps the year to the period whose band
contains it, scoped to the requested building type.
Year resolution reads Code_ConstructionYearClass, Year1_Building and
Year2_Building, which build_db already loads from the workbook. The
Year1 0 and Year2 9999 open-ended sentinels need no special case, a
plain range comparison covers them. A year with no archetype of that
type returns an empty match list rather than an error.
New GET /api/v1/periods/{cc} lists a country's bands as
{ period, year_from, year_to }, oldest first, for callers that want to
present the choices.
Adds TabulaReader.ResolvePeriodByYear and ListPeriods with integration
coverage, handler tests for the year path and the both/neither 400, and
updates the OpenAPI spec and docs/api.md.
Closes #29
Claude-Session: https://claude.ai/code/session_01JBfY6ZG2W52imgy2M1JGYo
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
What
GET /api/v1/variants/{cc}/matchnow acceptsyearas an alternative toperiod. Exactly one of the two is required; both or neither is a 400. Withyear, ignis selects the period whose construction-year band contains it, scoped to the requested building type, then returns the same refurbishment-variant list as theperiodpath.periodis unchanged and backward compatible.New
GET /api/v1/periods/{cc}returns a country's bands as[{ period, year_from, year_to }], oldest first.year_from0 andyear_to9999 are passed through as the open-ended sentinels.How
TabulaReader.ResolvePeriodByYear(tableName, typePrefix, year)andListPeriods(tableName)readCode_ConstructionYearClass,Year1_Building,Year2_Building. These are already DB columns:build_dbcreates one per workbook header, so no loader change was needed.Year1_Building = 0/Year2_Building = 9999open-ended bands need no special case; a plainYear1 <= year <= Year2comparison covers them. Verified against real rows (e.g.AT.01= 0..1918,SI.06= 2009..9999).CC.N.TYPE, so a year with no archetype for that type (e.g. DE terraced houses have no pre-1860 band) returns an empty match list, not an error.Tests
ListPeriodsordering and sentinel passthrough.ListPeriodssuccess, unknown country, repo error.go test ./...,go test -tags integration ./internal/db/...,go vet ./...,make schema-check, and redocly lint on the OpenAPI spec all pass.Docs
OpenAPI spec (
yearparam,/periodspath,PeriodsResponse/ConstructionPeriodschemas) anddocs/api.mdupdated.Closes #29
https://claude.ai/code/session_01JBfY6ZG2W52imgy2M1JGYo