Skip to content

Feat/merge search - #313

Closed
AlexAxthelm wants to merge 2 commits into
feat/merge-paginationfrom
feat/merge-search
Closed

AlexAxthelm wants to merge 2 commits into
feat/merge-paginationfrom
feat/merge-search

Conversation

@AlexAxthelm

Copy link
Copy Markdown
Collaborator

Allow searching the merge review queue. Using a numeric search query (123) will also return candidates that include that resource.

Search is set up so that if any of the component resources match the query, then that candidate is included in the result set.


Stacked on #310 (Merge Review pagination). Review that first; this PR's diff is against feat/merge-pagination.

Why

Reviewers working through a long Merge Review queue had no way to find a specific field without paging through every candidate. STIT-745 asks for a search box over the candidate list.

What changed

API: GET /oil-gas-fields/merge-candidates?q=

  • Matching rule: a candidate matches when any of its resources, or its merged resource once approved, matches the Resource List's existing search. That's a case-insensitive substring of the merged name, local name, basin, state/province or region, licensed sources only.
  • Numbers: a numeric q also matches resource IDs, so q=2024 finds both "Block 2024" and resource 2024. Candidate IDs are not searched.
  • Approved candidates: they need no special case. Their emptied originals are already excluded by the resource universe, so only the merged resource can match.
  • Combining: q is ANDed with status, sort and paging. It narrows items / total_count; status_counts stays whole-queue, so the header doesn't change while you search.
  • base_resource_query change: it gains an optional resource_ids argument (passed through to the existing construct_base_query_statement support). The merge search uses it to search only resources that belong to candidates instead of the whole table. This touches the Resource List's shared query code; the Resource List's own call is unchanged.

Merge Review page

  • Layout: a search box across the top of the queue, with the Status filter and sort select below it.
  • Behavior matches the Resource List's search:
    • It submits on Enter or the Search button.
    • It clears on × or when the box is emptied.
    • Typing alone sends no requests.
  • URL: the search lives in the URL as q (documented in the frontend README under "Merge review URLs"). A new search returns to page 1, and Back/Forward re-fill the box.
  • Empty state: "No candidates match this search."

How to review

  1. deployments/api/src/stitch/api/db/queries.py: the resource_ids scoping in _resource_universe / base_resource_query.
  2. deployments/api/src/stitch/api/db/merge_candidate_actions.py: _resource_ids_matching and the q filter in list_merge_candidates.
  3. deployments/stitch-frontend/src/config/mergeReviewParams.js, then QueueSearch in pages/MergeCandidateReviewPage.jsx.

Known limitations

  • Wildcards: % and _ in a search act as SQL wildcards. This is existing Resource List search behavior, reused here unchanged.
  • Non-ASCII digits: a search made only of non-ASCII digit characters (e.g. ²) returns a server error rather than a text search.

Testing

  • make check passes.
  • API integration (SQLite):
    • a name match on either resource
    • a basin match
    • an approved candidate found by its merged resource
    • a numeric q matching a resource ID, digits in a name, and an over-long number (searched as text only, without erroring)
    • candidate IDs not searched
    • search combined with a status filter, with status_counts unchanged
    • a blank q treated as no search
    • names from unlicensed sources not matching
  • Observability: the new merge_candidates.list.search_scope / merge_candidates.list.search query labels.
  • Frontend:
    • q parse/serialize/trim in the URL schema
    • submit, Enter, clear and emptying the box
    • the box pre-filled from the URL
    • the empty-search message
    • q sent to the API

Manual verification: ran the local stack with the seeded queue from #310 (~220 candidates) and checked on the Merge Review page:

  • The search row and the stacked filters fit the queue column.
  • Name, basin and resource-ID searches find the expected candidates, including a match on either side of a pair.
  • An approved candidate is found by its merged field's name.
  • Clearing restores the full queue, and Back/Forward re-fill the box.

AI assistance

Claude Code was used to explore the codebase, plan the change, and write the implementation, tests and docs. Matching scope, ID matching and the layout were decided by the author during planning.

🤖 Generated with Claude Code

@AlexAxthelm
AlexAxthelm changed the base branch from main to feat/merge-pagination October 2, 2026 14:46
@AlexAxthelm
AlexAxthelm requested a balanced review from Copilot October 2, 2026 14:46
@AlexAxthelm
AlexAxthelm added this pull request to stack #314 October 2, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

AlexAxthelm and others added 2 commits October 2, 2026 16:56
Add `q` to GET /oil-gas-fields/merge-candidates. A candidate matches
when any of its resources, or its merged resource once approved,
matches the resource list's search (substring of the coalesced name,
local name, basin, state/province or region, licensed sources only). A
numeric q also matches resource ids; candidate ids are not searched.
The search runs only over resources that belong to candidates, via a
new optional `resource_ids` argument on base_resource_query. Header
status_counts stay whole-queue.

The queue gets a full-width search box above the stacked Status filter
and sort select. It submits on Enter or the Search button, clears on ×
or an emptied box, and lives in the URL as `q`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Name, basin or resource ID" was cut off in the narrow queue column.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Numeric searches can return repointed resources and sufficiently long digit strings can cause server errors.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Comment on lines +297 to +301
with named_query("merge_candidates.list.search"):
matching = set(await session.scalars(text_match))

if q.isdigit() and int(q) <= _MAX_RESOURCE_ID and int(q) in queue_resource_ids:
matching.add(int(q))
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

CD summary 8835a99

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

Deployments (4)
service url fqdn
api open pr-0313-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io
entity-linkage open pr-0313-el.purplegrass-c07d0a94.westus2.azurecontainerapps.io
frontend https://witty-mushroom-017a3dc1e-313.westus2.1.azurestaticapps.net
stitch-llm open pr-0313-llm.purplegrass-c07d0a94.westus2.azurecontainerapps.io
Database (1)
db_name postgres_host postgres_port postgres_db
pr_0313 stitch-dev.postgres.database.azure.com 5432 pr_0313
Jobs (2)
job image postgres_db api_url auth_mode
db-migrations ghcr.io/rmi/stitch-api:pr-0313@sha256:bd4e85fb41a018be20fa2ca41f80df2f62b4c1ad20ea09031a0c436a3ccd00df pr_0313
seed ghcr.io/rmi/stitch-seed:pr-0313@sha256:90014c570db968c05eba40f38df5ae0d782ede2104cd470bcbef400cabb2bd19 https://pr-0313-api.purplegrass-c07d0a94.westus2.azurecontainerapps.io/api/v1 stitch-client-bearer-token
Images (4)
build_time commit_time git_sha image image_digest
2026-10-02T14:57:17Z 2026-10-02T14:56:55Z a469ce4 ghcr.io/rmi/stitch-api:pr-0313 ghcr.io/rmi/stitch-api:pr-0313@sha256:bd4e85fb41a018be20fa2ca41f80df2f62b4c1ad20ea09031a0c436a3ccd00df
2026-10-02T14:57:16Z 2026-10-02T14:56:55Z a469ce4 ghcr.io/rmi/stitch-entity-linkage:pr-0313 ghcr.io/rmi/stitch-entity-linkage:pr-0313@sha256:b18f98bf17740dab52003d8f6dfe9a256e5d687ea0753d0bdc838b7643fb88fe
2026-10-02T14:57:17Z 2026-10-02T14:56:55Z a469ce4 ghcr.io/rmi/stitch-seed:pr-0313 ghcr.io/rmi/stitch-seed:pr-0313@sha256:90014c570db968c05eba40f38df5ae0d782ede2104cd470bcbef400cabb2bd19
2026-10-02T14:57:17Z 2026-10-02T14:56:55Z a469ce4 ghcr.io/rmi/stitch-stitch-llm:pr-0313 ghcr.io/rmi/stitch-stitch-llm:pr-0313@sha256:fe39149cd524980e13323c129f3f3973e33ad026bf1d3ee12940ad3a7745064b

@jdhoffa

jdhoffa commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Electing to close this and prioritize focusing on performance improvements.

@jdhoffa jdhoffa closed this Oct 9, 2026
@jdhoffa
jdhoffa deployed to development October 9, 2026 13:05 — with GitHub Actions Active
@jdhoffa
jdhoffa deployed to development October 9, 2026 13:05 — with GitHub Actions Active
@jdhoffa
jdhoffa deployed to development October 9, 2026 13:05 — with GitHub Actions Active
@jdhoffa
jdhoffa deployed to development October 9, 2026 13:05 — with GitHub Actions Active
@jdhoffa
jdhoffa deployed to development October 9, 2026 13:05 — with GitHub Actions Active
@jdhoffa
jdhoffa deployed to development October 9, 2026 13:05 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
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.

3 participants