Skip to content

web: add DZDP concentration view to geolocation explorer#559

Open
nikw9944 wants to merge 12 commits into
mainfrom
nikw9944/lake-550
Open

web: add DZDP concentration view to geolocation explorer#559
nikw9944 wants to merge 12 commits into
mainfrom
nikw9944/lake-550

Conversation

@nikw9944

@nikw9944 nikw9944 commented May 2, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

  • Add DZDP concentration view to the geolocation explorer page with hero stat cards, MapLibre anchor point map, country bar chart, ASN concentration list, methodology explainer, and CTA banner
  • Add view switcher (QA Explorer / DZDP Concentration / DZDP Validators) with URL query param sync (?view=) to the geolocation explorer page
  • Add slog.Warn logging and handle ClickHouse error code 81 (UNKNOWN_DATABASE) in geo concentration/validators handlers for better diagnostics when DZDP tables are unavailable

Resolves: #550

Diff Breakdown

Category Files Lines (+/-) Net
Core logic 4 +403 / -4 +399
Docs 2 +40 / -0 +40
Total 6 +443 / -4 +439

Mostly new frontend code — one large new component plus page-level wiring and minor API handler improvements.

Key files (click to expand)

Testing Verification

  • Concentration view handles loading, error, and empty states gracefully
  • View switcher correctly syncs with ?view= URL param, defaults to explorer for unknown values
  • All data rendered via React JSX auto-escaping (no XSS risk)
  • Verified geo handler warning log appears in PR preview API logs when DZDP tables are unavailable

@nikw9944 nikw9944 force-pushed the nikw9944/lake-550 branch from c16258d to f0c1137 Compare May 2, 2026 18:04
@nikw9944 nikw9944 changed the base branch from main to nikw9944/lake-549 May 2, 2026 18:04
@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown

🔗 Preview: https://pr-559.data.malbeclabs.com

@nikw9944 nikw9944 force-pushed the nikw9944/lake-550 branch from 350a34f to 179d5f9 Compare May 2, 2026 18:32
@nikw9944 nikw9944 changed the base branch from nikw9944/lake-549 to main May 2, 2026 18:32
@nikw9944 nikw9944 changed the base branch from main to nikw9944/lake-549 May 2, 2026 18:47
@nikw9944 nikw9944 force-pushed the nikw9944/lake-550 branch 3 times, most recently from 29968b0 to e0673bf Compare May 4, 2026 02:38
@nikw9944 nikw9944 force-pushed the nikw9944/lake-549 branch from 87ea79c to 65459d4 Compare May 5, 2026 19:15
Base automatically changed from nikw9944/lake-549 to main May 5, 2026 20:15
@nikw9944 nikw9944 force-pushed the nikw9944/lake-550 branch from e0673bf to f35361c Compare May 5, 2026 20:18
@nikw9944 nikw9944 marked this pull request as ready for review May 5, 2026 20:19
@nikw9944 nikw9944 requested a review from ben-dz May 5, 2026 20:19
@nikw9944 nikw9944 force-pushed the nikw9944/lake-550 branch from f35361c to 291f341 Compare May 5, 2026 20:30
nikw9944 added 4 commits May 5, 2026 20:42
Add view switcher (QA Explorer / DZDP Concentration / DZDP Validators)
with URL query param sync and full DZDP concentration view including
hero stat cards, anchor point map, country bar chart, ASN concentration
list, how-it-works strip, and CTA banner.
Use fetchWithRetry for consistency with other API functions, and
memoize setView callback in the view switcher.
The types and fetch function are already provided by the #549 branch.
The geo concentration and validators handlers silently returned empty
responses when DZDP tables were unavailable (ClickHouse error code 60).
This made it impossible to diagnose why PR preview environments showed
empty data. Add slog.Warn logging and also handle error codes 81
(UNKNOWN_DATABASE) and 497 (NOT_ENOUGH_PRIVILEGES) which occur when the
ClickHouse user lacks grants on the dzdp database.
@nikw9944 nikw9944 force-pushed the nikw9944/lake-550 branch from 291f341 to 2cb8896 Compare May 5, 2026 20:42

@ben-dz ben-dz 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.

Scrolling seems to be broken in the preview. The data at the bottom cuts off wherever the browser window ends. Perhaps make the cotent layout and map size dynamic based on the size of the window, then have the tables scroll?

@ben-dz ben-dz 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.

"No Metro coordinate data available" flashes up when the page is loading- perhaps a different "Loading Metro Coordinate data" makes more sense during load?

@ben-dz

ben-dz commented May 8, 2026

Copy link
Copy Markdown
Contributor

Names are getting cut off in the stake by country section.
image

@ben-dz

ben-dz commented May 8, 2026

Copy link
Copy Markdown
Contributor

Names of metros are moving around really weirdly on the map when scrolling out
image

nikw9944 added 2 commits May 8, 2026 15:24
- Make map height dynamic using clamp(250px, 40vh, 500px) instead of
  fixed 400px so content doesn't cut off at browser window edge
- Add min-h-0 to content container for proper flex overflow scrolling
- Add max-height with overflow scroll to ASN list
- Show "Loading metro coordinate data" spinner instead of "No metro
  coordinate data available" while metros query is in flight
nikw9944 added 4 commits May 8, 2026 20:22
Drop the CROSS JOIN + geoDistance + arraySort CTEs from both geo
handlers. The SQL now returns enriched validators with lat/lng, and Go
assigns the nearest metro using Haversine distance and deduplicates by
vote_pubkey.

The query itself runs in ~30ms but was timing out under contention when
heavy queries (edge scoreboard, bulk metrics) saturated ClickHouse
memory. Removing the CROSS JOIN and two GROUP BY CTEs reduces the
ClickHouse work and memory footprint, making the query more resilient
to concurrent load.
# Conflicts:
#	api/handlers/geo_validators.go
The DzdpConcentrationView's overflow-y-auto requires all ancestor
flex-col containers to have min-h-0. Without it, the content could
extend beyond the viewport instead of scrolling within the page.
@nikw9944 nikw9944 removed the preview label Jun 29, 2026
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.

geoloc explorer for DZDP issue B: geolocation explorer view

2 participants