Skip to content

fix(data-api): port neurons-derived concentration/performance/yield/portfolio handlers to Postgres#4837

Merged
JSONbored merged 1 commit into
mainfrom
fix/tier2-neuron-daily-postgres-tier
Jul 11, 2026
Merged

fix(data-api): port neurons-derived concentration/performance/yield/portfolio handlers to Postgres#4837
JSONbored merged 1 commit into
mainfrom
fix/tier2-neuron-daily-postgres-tier

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Tier 2a of fix(data-api): 25 more D1-only handlers — some serving frozen data since the streamer stopped #4832: adds the Postgres tier for the 8 handlers reading the live neurons snapshot that hadn't been ported yet — handleSubnetConcentration, handleSubnetPerformance, handleChainConcentration, handleChainPerformance, handleChainYield, handleSubnetYield, handleAccountPortfolio, handleAccountsList.
  • Adds the matching 8 routes to workers/data-api.mjs, wires tryPostgresTier into each handler in workers/request-handlers/entities.mjs with the established fallback-to-D1-on-any-failure contract.
  • Fixes a real bug caught while testing handleAccountsList: Number(url.searchParams.get("limit")) silently evaluates an absent ?limit= to 0 (finite), returning an empty leaderboard page instead of the intended default — guarded with an explicit presence check.

Test plan

  • npx vitest run tests/data-api.test.mjs tests/request-handlers-entities.test.mjs — 470 + 165 tests pass, including 16 new postgres-wins/falls-back-to-D1 pairs for the 8 handlers
  • npx vitest run (full repo) — 259 files / 7330 tests pass
  • npm run lint / npx prettier --check on touched files — clean
  • npm run scan:public-safety — clean
  • npm run test:coverage + manual codecov/patch-style branch-coverage isolation on the diff — all uncovered branches confirmed pre-existing/outside the patch's added-line ranges

Refs #4832

…ortfolio handlers to the Postgres tier

Tier 2a of #4832: handleSubnetConcentration, handleSubnetPerformance,
handleChainConcentration, handleChainPerformance, handleChainYield,
handleSubnetYield, handleAccountPortfolio, and handleAccountsList were
still D1-only despite reading the same live `neurons` snapshot already
served by the Postgres tier for /metagraph and /neuron. Adds the 8
matching routes to the data Worker and wires tryPostgresTier into each
handler with the established fallback contract.

Also fixes a real bug caught by the new accounts-list tests: an absent
`?limit=` coerced through Number() evaluates to 0 (finite), silently
returning an empty leaderboard instead of the intended default.

Refs #4832
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
metagraphed-data-api ca108fe Commit Preview URL

Branch Preview URL
Jul 11 2026, 03:36 AM

@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.76%. Comparing base (113584b) to head (ca108fe).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4837   +/-   ##
=======================================
  Coverage   97.76%   97.76%           
=======================================
  Files         162      162           
  Lines       19004    19038   +34     
  Branches     7122     7141   +19     
=======================================
+ Hits        18579    18613   +34     
  Misses         59       59           
  Partials      366      366           
Files with missing lines Coverage Δ
workers/data-api.mjs 99.51% <100.00%> (+0.03%) ⬆️
workers/request-handlers/entities.mjs 99.34% <100.00%> (-0.01%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored merged commit 59ecd58 into main Jul 11, 2026
14 checks passed
@JSONbored JSONbored deleted the fix/tier2-neuron-daily-postgres-tier branch July 11, 2026 03:40
@JSONbored JSONbored self-assigned this Jul 11, 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.

1 participant