Skip to content

Feat/filter options#103

Draft
AlexAxthelm wants to merge 5 commits into
mainfrom
feat/filter-options
Draft

Feat/filter options#103
AlexAxthelm wants to merge 5 commits into
mainfrom
feat/filter-options

Conversation

@AlexAxthelm
Copy link
Copy Markdown
Collaborator

@AlexAxthelm AlexAxthelm commented May 25, 2026

Exposes an authenticated endpoint that lists distinct values for a field, as constructed using the user's permissions and standard coalescing rules (different users will see different result sets here), and update frontend to make use of it.

Eliminates behavior of filter dropdowns only showing values from the currently displayed page of PaginatedResponse

Supported by codex

Tested locally with auth, and in the PR environment:

@github-actions
Copy link
Copy Markdown

CD summary 77188f0

Deployments (3)
service url fqdn
api open pr103-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io
entity-linkage open pr103-entity-linkage.purplegrass-c07d0a94.westus2.azurecontainerapps.io
stitch-llm open pr103-stitch-llm.purplegrass-c07d0a94.westus2.azurecontainerapps.io
Database (1)
db_name postgres_host postgres_port postgres_db
pr_103 stitch-dev.postgres.database.azure.com 5432 pr_103
Jobs (2)
job image postgres_db api_url auth_mode
db-init ghcr.io/rmi/stitch-api:pr103@sha256:1970a472af80e03c80a1409eb5ab1d97206693707c61946026561a83d53f2a27 pr_103
seed ghcr.io/rmi/stitch-seed:pr103@sha256:4c6ac17074a4bfcfdd64112969eda08d14964b00b63acd8af413d4e01716a921 https://pr103-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io/api/v1 dev placeholder bearer token
Images (4)
build_time commit_time git_sha image image_digest
2026-05-25T10:19:54Z 2026-05-25T10:19:38Z 45442a5 ghcr.io/rmi/stitch-api:pr103 ghcr.io/rmi/stitch-api:pr103@sha256:1970a472af80e03c80a1409eb5ab1d97206693707c61946026561a83d53f2a27
2026-05-25T10:19:53Z 2026-05-25T10:19:38Z 45442a5 ghcr.io/rmi/stitch-entity-linkage:pr103 ghcr.io/rmi/stitch-entity-linkage:pr103@sha256:e5604687cc3903ce71d2e454f0e53f31b2950dd3aeaba22b7c9491699e040cb4
2026-05-25T10:19:51Z 2026-05-25T10:19:38Z 45442a5 ghcr.io/rmi/stitch-seed:pr103 ghcr.io/rmi/stitch-seed:pr103@sha256:4c6ac17074a4bfcfdd64112969eda08d14964b00b63acd8af413d4e01716a921
2026-05-25T10:19:49Z 2026-05-25T10:19:38Z 45442a5 ghcr.io/rmi/stitch-stitch-llm:pr103 ghcr.io/rmi/stitch-stitch-llm:pr103@sha256:828fe7f5e88c467f6ce995d953dc50beb4ede7291ff44e6e924855c2cbffc9b5

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a backend + frontend flow for loading distinct dropdown filter values from a dedicated “filter-options” endpoint, instead of computing options from the currently loaded page of resources. It also updates the UI to keep the filter bar visible even when the current result set is empty.

Changes:

  • Add GET /oil-gas-fields/filter-options (with field + optional source) and a DB action to return distinct, sorted, coalesced resource values.
  • Add frontend API/query/hook support for fetching filter options, and update FilterBar to use the new queries.
  • Add router/unit/db integration tests for the new endpoint/action and update UI tests accordingly.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
PLAN.md Documents the intended behavior, scope, and test plan for the filter-options endpoint.
deployments/stitch-frontend/src/queries/resources.js Adds query key + query definition for filter-options requests.
deployments/stitch-frontend/src/queries/api.js Adds getResourceFilterOptions() API helper.
deployments/stitch-frontend/src/queries/api.test.js Adds unit tests for getResourceFilterOptions().
deployments/stitch-frontend/src/hooks/useResources.js Adds useResourceFilterOptions (real + mock) hook.
deployments/stitch-frontend/src/components/ResourcesView.jsx Renders FilterBar when data is present (even if items is empty) and passes endpoint.
deployments/stitch-frontend/src/components/ResourcesView.test.jsx Updates mocks/tests to cover new filter-options hook usage and filter bar visibility on empty results.
deployments/stitch-frontend/src/components/FilterBar.jsx Switches from local option counting to loading options via useResourceFilterOptions.
deployments/stitch-frontend/src/components/FilterDropdown.jsx Hides the count column when counts aren’t provided (new options omit counts).
deployments/api/src/stitch/api/entities.py Adds FilterOptionField, params, and response models for filter-options.
deployments/api/src/stitch/api/routers/oil_gas_fields.py Adds /filter-options route returning OGFieldFilterOptionsResponse.
deployments/api/src/stitch/api/db/og_field_resource_actions.py Adds filter_options() DB action using the coalesced resource CTE to return distinct values.
deployments/api/tests/routers/test_resources_unit.py Adds unit tests for the new router endpoint (including licensed source forwarding).
deployments/api/tests/routers/test_query_param_validation.py Adds validation test ensuring unsupported field values return 422.
deployments/api/tests/db/test_resource_actions.py Adds integration tests verifying distinct/sorted/null-filtered behavior and licensing/scoping behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread deployments/api/src/stitch/api/db/og_field_resource_actions.py Outdated
Comment on lines +109 to +113
)

coalesced = _build_licensed_resource_list_cte(params, licensed_sources)
col = _resource_list_column(coalesced, params.field)
if col is None:
Copy link
Copy Markdown
Collaborator Author

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.

@github-actions
Copy link
Copy Markdown

CD summary 98999d1

Frontend: https://witty-mushroom-017a3dc1e-103.westus2.1.azurestaticapps.net

Deployments (4)
service url fqdn
api open pr103-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io
entity-linkage open pr103-entity-linkage.purplegrass-c07d0a94.westus2.azurecontainerapps.io
frontend https://witty-mushroom-017a3dc1e-103.westus2.1.azurestaticapps.net
stitch-llm open pr103-stitch-llm.purplegrass-c07d0a94.westus2.azurecontainerapps.io
Database (1)
db_name postgres_host postgres_port postgres_db
pr_103 stitch-dev.postgres.database.azure.com 5432 pr_103
Jobs (1)
job image postgres_db
db-init ghcr.io/rmi/stitch-api:pr103@sha256:2eab05c990237905f658eb9a552527609088a43bc33ca0033809ff29823c02cc pr_103
Images (4)
build_time commit_time git_sha image image_digest
2026-05-25T10:26:33Z 2026-05-25T10:26:24Z ef248b3 ghcr.io/rmi/stitch-api:pr103 ghcr.io/rmi/stitch-api:pr103@sha256:2eab05c990237905f658eb9a552527609088a43bc33ca0033809ff29823c02cc
2026-05-25T10:26:36Z 2026-05-25T10:26:24Z ef248b3 ghcr.io/rmi/stitch-entity-linkage:pr103 ghcr.io/rmi/stitch-entity-linkage:pr103@sha256:aaa8bbbe45973b45829cd0425b93dd91f9d2aab38d6357a0633cf6bfd8883c9c
2026-05-25T10:26:36Z 2026-05-25T10:26:24Z ef248b3 ghcr.io/rmi/stitch-seed:pr103 ghcr.io/rmi/stitch-seed:pr103@sha256:531744bb68a3f382c56e5444b70dac34d2a06d32ea3e23625e446b5b0e9a482e
2026-05-25T10:26:33Z 2026-05-25T10:26:24Z ef248b3 ghcr.io/rmi/stitch-stitch-llm:pr103 ghcr.io/rmi/stitch-stitch-llm:pr103@sha256:b8b5bf9e78eada3e1e427d5f49e4456131e618151f21cea53e5b0f42dc8efb2e

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