Skip to content

fix(api): match only the subtype's own refurbishment variants - #61

Merged
jravani merged 1 commit into
mainfrom
fix/match-own-subtype-refurbishment
Oct 20, 2026
Merged

jravani merged 1 commit into
mainfrom
fix/match-own-subtype-refurbishment

Conversation

@jravani

@jravani jravani commented Oct 20, 2026

Copy link
Copy Markdown
Member

Summary

GET /api/v1/variants/{country}/match now returns only TABULA's standard refurbishment variants (ReEx.001.001, .002, .003) of one building subtype, labelled by variant number instead of by position.

Before, every variant of the type and period came back, so other subtypes and alternative packages appeared as "Refurbishment level 4" and up. For example, NL SFH 03 listed the Deta variants and then the Gen ones as levels 4 to 6.

API change

Item Change
subtype query parameter New, optional, default Gen. Case as in TABULA codes (Deta, Semi, Bel80).
prefix Now includes the subtype: DE.N.SFH.06.Gen instead of DE.N.SFH.06.
subtype response field New, echoes the subtype used.
data[].number New, TABULA's Number_BuildingVariant (1, 2 or 3).
data[].description New, TABULA's Description_BuildingVariant, empty where TABULA gives none.
data[].label The description when present, otherwise "Existing state", "Usual refurbishment" or "Advanced refurbishment".

A subtype that lacks a standard variant returns only those it has: the newest BE and NL periods return variants 1 and 3. A subtype with none returns an empty data list, for example HU AB 02 Ind, which is numbered from .011.

Verification

  • go vet ./... and go test ./... pass.
  • The integration suites (./internal/utils/ ./internal/db/ ./internal/db/repository/) pass. A new belgium fixture mixes two subtypes, a missing variant 2, .004 and ReEx.002.*.
  • make schema-check passes.
  • Old and new responses compared on a database built from the workbook:
Query Before After
NL SFH 03 6 entries, Deta then Gen as levels 4 to 6 3 Gen entries
DE SFH 11 9 entries, .011 to .023 as levels 4 to 9 3 entries, TABULA's construction-standard wording
BE TH 05 Semi 4 entries across Gen and Semi, .003 labelled medium Semi variants 1 and 3
HU AB 02 Ind .011 to .013 labelled existing, medium, advanced empty list

GET /variants/:country/match returned every variant whose code began
with CC.N.TYPE.PERIOD and labelled them by position: existing state,
medium, advanced, then "Refurbishment level N". Where a period has
several subtypes (48 of 400 type and period groups) or extra variants
(.004, .011 to .053, ReEx.002.*), other subtypes and alternative
packages were presented as deeper refurbishment. NL SFH 03 returned
Deta .001 to .003 followed by Gen as "Refurbishment level 4" to 6.

The endpoint now takes an optional subtype query parameter, default
Gen, and returns only TABULA's standard variants ReEx.001.001, .002
and .003 of CC.N.TYPE.PERIOD.SUBTYPE, ordered by
Number_BuildingVariant. The response echoes subtype, and prefix now
includes it.

Each entry gains number and description. description is TABULA's
Description_BuildingVariant, empty where the workbook stores "0".
label is the description when there is one, otherwise TABULA's name
for the number: Existing state, Usual refurbishment, Advanced
refurbishment. In recent periods the standard variants are
construction standards (DE SFH 11: KfW Effizienzhaus 70, passive
house), which the generic names would misstate.

Labelling by number rather than position also fixes subtypes that
lack a variant: the newest BE and NL periods return variants 1 and 3,
and HU and IE groups numbered only from .011 return an empty list.

The OpenAPI spec and docs/api.md describe the new parameter and
fields.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/db/repository/tabula_repository.go 75.00% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@jravani
jravani merged commit 71ea484 into main Oct 20, 2026
6 checks passed
@jravani
jravani deleted the fix/match-own-subtype-refurbishment branch October 20, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants