feat: Add version filtering to metadata endpoints #72
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.
Summary
This PR adds optional
tax_benefit_model_version_idfiltering to the metadata endpoints (/parameters/,/variables/,/parameter-values/). When only a model name is provided (without an explicit version ID), endpoints now default to returning data from the latest version (determined bycreated_attimestamp).Key Changes
New shared service:
src/policyengine_api/services/tax_benefit_models.pywith helper functions:get_latest_model_version()- Get the latest version for a model nameget_model_version_by_id()- Get a specific version by UUIDresolve_model_version_id()- Resolve version ID from either explicit ID or model nameUpdated endpoints:
/parameters/- Addedtax_benefit_model_version_idfilter/variables/- Addedtax_benefit_model_version_idfilter/parameter-values/- Added bothtax_benefit_model_nameandtax_benefit_model_version_idfiltersRefactored:
/analysis/economic-impactnow uses the shared helper instead of its own duplicate functionBehavior
tax_benefit_model_nameprovidedtax_benefit_model_version_idprovidedtax_benefit_model_version_idtakes precedenceTest plan
🤖 Generated with Claude Code