Skip to content

feat(editor): show counts next to every filter dropdown option, for the region or nationwide - #168

Merged
prayaslashkari merged 2 commits into
developmentfrom
feat/option-counts-165
Nov 17, 2026
Merged

prayaslashkari merged 2 commits into
developmentfrom
feat/option-counts-165

Conversation

@prayaslashkari

Copy link
Copy Markdown
Collaborator

Closes #165

Summary

Every filter dropdown now counts its options, for the block's region or nationwide with none. A count is the run's own count step with the filter left open, so it checks the region exactly as the run does.

 buildEntityCountQuery(block, region)        # count step, opens every run
   ?s2probe a S2Cell_Level13
   regionClause(type, region)                # cell + the type's regionCheck
   bindInCell(block)
+buildOptionCountQuery(type, region)         # new: one row per option
+  ?s2probe a S2Cell_Level13
+  regionClause(type, region)                # same code, same lines
+  entity.options.bind(?option)              # bindInCell with the filter open
+GROUP BY ?option
Dropdown Before After
Industry counts only once a state is picked region or nationwide
Feature Type none region or nationwide, parents sum children
Aquifer Type none region or nationwide, raw values summed per option
Well classification whole of IL or ME only region or nationwide
useOptionCounts(type, region)                # ['optionCounts', type, sorted codes], staleTime Infinity
  executeSparql('federation', buildOptionCountQuery)
  optionCountsFrom(type, rows)               # keyed via entity.options.key

buildIndustryCountsQuery / useIndustryCounts are removed (they skipped the #145 facility region check).

Evidence

  • Before: Hancock wells counted by subdivision link alone: 11,644. The run finds 7,296.
    After: the count uses the run's check. Hancock Maine bedrock wells: 7,236 (live, 2026-11-17).

  • Before: Feature Type in Maine showed no numbers.
    After (read from the running app):

    Surface Water Bodies (6,612)    Streams and Flowlines (29,677)
      Lake / Pond (4,412)             Stream / River (18,922)
      Swamp / Marsh (2,191)           Artificial Path (10,396)
      Reservoir (9)                   Canal / Ditch (48) · Connector (310) · Pipeline (1)
    
  • Tests (npm test: 638 passed, query-shapes.txt unchanged):

    engine/tests/optionCounts.test.ts
      for each counted type x [none, state, county, two counties]
        regionLines(optionCountQuery) == regionLines(countStepQuery)   # fails if a count skips the regionCheck
      rows to counts: aquifer raw values summed, NAICS IRI to bare code, IL twins summed
    ui/tests/optionCounts.test.tsx
      Aquifer "Bedrock (1)" for Cook · Feature Type rollup · Industry nationwide
      Wells show county counts, not statewide · failed count leaves dropdown usable
      same counties in another order: no refetch
    
  • Live cost (first run, federation): 1.8s or less for every type, nationwide and for ME, Hancock, IL. Exception: Illinois aquifers cold took 30.1s (0.46s rerun; the run's own count step for that block took 25.8s cold), so the first open there may show no numbers.

npm run build passes. npm run lint: the 15 pre-existing errors, none new.

Merge Danger

Door: two-way

No stored data, no cache key or wire change, and no change to the SPARQL any question sends. Revert restores the old dropdowns.

Blast Radius: editor dropdowns

Opening a filter panel now sends one count query per type and region per session to federation (two for Surface Water, which counts water bodies and flowlines together). Wiki "Industry counts" page is retitled "Option counts" (same file, links unchanged).

…he region or nationwide

Industry, Feature Type, Aquifer Type and Well classification now show how
many entities each option would find: in the selected state or counties, or
nationwide with none. Each count is the run's own count step with the filter
left open (buildOptionCountQuery), so it checks the region exactly as the run
does. Hancock wells: 7,296, where a subdivision-only count gave 11,644.

Live queries on federation, cached for the session, no stored values. Measured
2026-11-17: 1.8s or less everywhere except Illinois aquifers cold (30s).

Closes #165
@railway-app

railway-app Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the explorer-app-pr-168 environment in sawgraph-explorer

Service Status Web Updated
sawgraph-api ❌ Build Failed (View Logs) Web Nov 17, 2026 at 9:25 pm UTC
sawgraph-web ✅ Success (View Logs) Web Nov 17, 2026 at 9:20 pm UTC
1 service not affected by this PR
  • sawgraph-db-dev

@prayaslashkari
prayaslashkari merged commit 2410fb1 into development Nov 17, 2026
2 of 3 checks passed

This branch had an error being deployed

1 failed deployment
sawgraph-explorer / explorer-app-pr-168 — 40064342 Deployed Nov 17, 2026 by railway-app[bot]
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.

1 participant