Repository navigation
fix: standardise range queries to half-open intervals [from, to) (#236) - #584
Conversation
|
@Nwapu-TrustJah Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
tsc --noEmit clean vitest 106 files, 1232 passing (up from 102 / 1157) dropped-tests none Four of the eight screened in this group. The other four were held, and the reason is worth stating because it keeps recurring: each one merges cleanly and fails on its own. #590 72 type errors alone, including syntax errors in src/api/rest.ts and src/api/schemas.ts -- "Declaration or statement expected", "Expression expected". Not type mismatches; the file does not parse. #584 3 type errors alone #592 conflicts #595 conflicts Merged together before screening, that group produced 68 failing test files and syntax errors I first mistook for a bad three-way merge. They were not: #590 carries them on its own branch. Screening each PR individually before batching costs one typecheck per PR and saves an hour of bisection, which is the lesson of the day. Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
Miracle656
left a comment
There was a problem hiding this comment.
Three type errors on its own branch against current main — npx tsc --noEmit will show them after a rebase.
Standardising range queries to half-open intervals [from, to) is the right call and worth doing properly: with closed intervals, consecutive windows double-count the boundary row, which quietly inflates every volume and count that straddles it. That is the kind of error nobody notices because the number still looks plausible.
Worth adding a test that pins exactly that, if there is not one already: two adjacent windows over a row that sits on the boundary should total the same as one window covering both.
d7add2b to
e37c85e
Compare
|
I have completed all the requested changes: |
|
Merged to
The network predicate is the bigger fix and it isn't in your title. The changeset is where I found it: The breaking-change note is also well written: saying plainly that callers relying on the inclusive end must widen One follow-up, deliberately out of scope here. Two closed-interval predicates remain:
So GraphQL Lens: 114 files, 1,411 tests passing, typecheck clean. |
#584 documented the half-open [from, to) semantics on the `from` and `to` query parameters in openapi.yaml, and the generated client carries those descriptions as JSDoc. I merged it without regenerating, so #403's `git diff --exit-code -- clients/typescript` guard failed on main — which is the guard doing exactly its job one merge after it was added. Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
computeTWAP already took a `network` and filtered on it (`AND network = $2`), but the routes never passed one, so the figures were computed for whatever the default was rather than the network the caller asked for. Same class of bug as #584 found in /candles, /basket and /benchmark — a price that silently mixes or mistakes chains. Both routes now resolve `req.network ?? query.network ?? activeNetwork`, thread it into the computation and echo it in the response, so a caller can see which chain answered. 122 lines of new route tests cover it. Conflicts, all additive against work that landed today: #542 added the decimal-format handling in the same schema and handler blocks this PR adds `network` to. Unioned — the query schema now carries decimals, decimalFormat and network, and the handler does both. Two things I regenerated rather than merged by hand: openapi.json, because it is generated from openapi.yaml and a hand-merged copy fails the generator-match test, and the TypeScript client, because #403's drift guard checks it. Took main's package-lock.json; this PR changes no dependency and main's is the copy carrying the @rolldown Linux binding CI needs. Lens: 116 files, 1,426 tests passing, typecheck clean. Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
listPairs returned bare strings, so a client wanting the assets, the network or a price had to parse the pair key and then ask again. `pairs` returns the structured form, and listPairs stays — deprecated with a reason rather than removed, which is the right call for a published API. The resolver is good: one query per request using a LATERAL join to pull the latest price for each active pair, rather than a query per pair, and scoped by `network = $1` so it cannot blend chains — the bug #584 and #605 both had to fix elsewhere today. Conflicts, resolved by keeping main's richer side and adding this PR's: - imports: kept main's (NetworkName, the oracle adapter and comparison) and added getActivePairs - the schema declaration: kept main's `export const schema`, which the SDL artifact generator depends on, and added the Asset and Pair types - the Query block: kept main's documented getPriceHistory with its from/to range and the oracle query, and added `pairs` plus the @deprecated marker on listPairs Regenerated schema.graphql afterwards. src/__tests__/graphqlSchemaDrift.test.ts compares the committed SDL against the code-defined schema, so adding types without regenerating fails it — the same generated-artifact guard as openapi.json and the TypeScript client. Lens: 118 files, 1,432 tests passing, typecheck clean. Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
Summary
Standardized all range queries across the codebase from inclusive upper bounds (
<=) to half-open intervals[from, to)(<) to prevent double-counting samples on shared boundaries. Updated OpenAPI specifications and added a dedicated adjacent-window test suite.Related issue
Closes #236
Type of change