-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/filter options #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlexAxthelm
wants to merge
6
commits into
main
Choose a base branch
from
feat/filter-options
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/filter options #103
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ed8833b
Add codex plan
AlexAxthelm ec83426
Add filter options endpoint to show filterable values
AlexAxthelm 77188f0
Use filter options endpoint in UI
AlexAxthelm 7097dd0
style: format
AlexAxthelm 98999d1
linting: prefer `get_args` to avoid type ignore
AlexAxthelm ddc756f
Merge branch 'main' into feat/filter-options
AlexAxthelm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| ## Resource Filter Options Endpoint | ||
|
|
||
| ### Summary | ||
| Add a read-only endpoint at `GET /oil-gas-fields/filter-options?field=country` that returns the distinct coalesced resource values visible to the current user for one requested field. The query must use the same resource-side coalescing and permission scoping as `GET /oil-gas-fields/`, but it will not apply the rest of the current list filters in this PR. | ||
|
|
||
| ### Key Changes | ||
| - Add a new endpoint under the existing `oil_gas_fields` router: | ||
| - `GET /oil-gas-fields/filter-options` | ||
| - Required query param: `field` | ||
| - Define a small response model in the API entities layer. | ||
| - Default assumption: `{ "field": "country", "values": ["CAN", "USA"] }` | ||
| - Keep `values` sorted ascending and omit `null` / empty-string values. | ||
| - Add a dedicated field-param type for this endpoint rather than reusing `OGFieldQueryParams`. | ||
| - Validate `field` against a whitelist of supported resource filter-option fields. | ||
| - Default assumption: support the coalesced scalar filter fields used by the table filters, not `q`, not list/JSON fields (`owners`, `operators`), and not raw-source-only fields. | ||
| - Implement a new DB action on top of the existing coalesced resource CTE in `og_field_resource_actions.py`. | ||
| - Reuse `_build_licensed_resource_list_cte(...)` so results match resource visibility and source-priority coalescing. | ||
| - Do not apply `_build_final_conditions(...)` in this endpoint. | ||
| - Do still pass `licensed_sources(claims)` and the selected `source` set, so the result reflects the user-visible resource universe. | ||
| - Keep this endpoint resource-based, not source-based. | ||
| - Distinct values come from the coalesced resource columns after permission scoping, never from raw source rows. | ||
|
|
||
| ### API / Behavior Details | ||
| - Request: | ||
| - `GET /oil-gas-fields/filter-options?field=country` | ||
| - Optional `source` query params may still be accepted if convenient, since source selection is part of resource visibility. | ||
| - Response: | ||
| - `field`: echoed requested field | ||
| - `values`: distinct visible values for that coalesced field | ||
| - Validation: | ||
| - Unknown or unsupported `field` returns `422`. | ||
| - Non-goal for this PR: | ||
| - No interaction with the rest of the active resource filters. | ||
| - This means the UI may later allow choosing a filter value that produces an empty result set; that is accepted for now. | ||
|
|
||
| ### Test Plan | ||
| - Router unit tests: | ||
| - `GET /oil-gas-fields/filter-options?field=country` returns `200` and the expected response envelope. | ||
| - Invalid field such as `owners` returns `422`. | ||
| - Router passes claims-derived licensed sources into the DB action. | ||
| - DB integration tests: | ||
| - Distinct values are computed from coalesced resource data, not individual source rows. | ||
| - Licensed-source restrictions remove values that only exist in unlicensed sources. | ||
| - Repointed / inactive-membership resources are excluded consistently with the main resource list. | ||
| - `null` and empty-string values are excluded. | ||
| - Results are sorted and deduplicated. | ||
|
|
||
| ### Assumptions | ||
| - The endpoint should ignore current non-source resource filters in this PR, per your direction. | ||
| - The response should be a simple object with `field` and `values`. | ||
| - Supported `field` values should be limited to resource-table filter fields, not every `OilGasFieldBase` attribute. |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbarlow12 open to input on the best way to handle this. My robot is suggesting a
Protocol, but that seems a bigger change than I want to slip into this PR.