feat(api): expose n_Apartment on GET /data/:code - #39
Merged
Merged
Conversation
Downstream building models scale occupancy-driven loads (internal gains, electricity, hot water) by the number of dwellings in a building. TABULA carries that count as n_Apartment, and every country table already holds the column because the workbook loader imports every header, but GET /api/v1/data/:code did not expose it, so a caller had to assume one dwelling per building. Add N_Apartment to BuildingThematic. GetVariant selects every column and the struct mapper matches by json tag, so no repository, handler, SQL or migration change is needed. The column is REAL in PostgreSQL; the mapper's float32 case converts it to int, and every stored value across the 20 country tables is a whole number. It lands at tabula_data.BasicParameters.BuildingAppearance.n_Apartment. SFH and TH variants carry 1, MFH and AB carry the archetype's dwelling count, and the three DK.N.AB.09 variants carry 0 because the workbook gives no count for them. Closes #38
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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.
Closes #38
What
GET /api/v1/data/{code}now returns the TABULA apartment count attabula_data.BasicParameters.BuildingAppearance.n_Apartment.internal/models/tabula.go:N_Apartment intwith json tagn_ApartmentonBuildingThematic.GetVariantselects every column and the struct mapper matches by json tag, so no repository, handler, SQL or migration change.docs/openapi/openapi.yaml: one sentence in theTabulaDatadescription. It is not listed underCalculateRequestbecause it is not an override and the calculate body rejects unknown fields.internal/db/repository/struct_mapper_test.go: asserts afloat32map value lands as int.internal/db/repository/repository_integration_test.go:tabula.netherlandsfixture with aREALcolumn; AB.03 returns 15, SFH.01 returns 1.Why
Downstream building models scale occupancy-driven loads by the number of dwellings. Without this field a caller has to assume one dwelling per building, which under-counts every apartment block.
Verification
go vet ./...,go build ./...,go test ./...pass.go test -tags integration ./internal/db/repository/passes against a testcontainers Postgres.Data notes
The column is
REALin PostgreSQL. All 2147 rows across the 20 country tables hold whole numbers, so the int conversion loses nothing. Three Denmark variants (DK.N.AB.09.Gen.ReEx.001.001to.003) hold 0 because the workbook gives no count; the OpenAPI text documents 0 as "no count".