Skip to content

ref(project-detail): Use relative period params for previous period queries#113100

Merged
gggritso merged 2 commits intomasterfrom
gg/stability-project-card-query-keys
Apr 15, 2026
Merged

ref(project-detail): Use relative period params for previous period queries#113100
gggritso merged 2 commits intomasterfrom
gg/stability-project-card-query-keys

Conversation

@gggritso
Copy link
Copy Markdown
Member

@gggritso gggritso commented Apr 15, 2026

Some of the cards on the Project Details pages cause re-fetch cascades:

Screenshot 2026-04-15 at 4 05 13 PM Screenshot 2026-04-15 at 4 06 08 PM

The loop is:

  1. Render the component
  2. Take the current period (e.g., 14d) and calculate the previous period to the second (e.g., 2026-03-17T16:15:00 - 2026-04-01T16:15:00)
  3. Fetch the data from the previous period using the previous period's timestamps
  4. Data arrives, re-render component
  5. Calculate new previous period (e.g., 2026-03-17T16:15:15 - 2026-04-01T16:15:15)

Loop forever. There are a few possible solutions here, including memoizing the component. Instead, I thought it would be simpler to use the same approach that some of the other card are using, which is the statsPeriodStart and statsPeriodEnd query parameters. Instead of a timestamp, they specify the start and end as strings, so e.g., 28d to 14d to fetch the previous period. This creates a stable query key for Tan Stack Query, and stops the refetch. We also could have, for example, dropped down to a bigger precision (instead of using seconds), but this seems the tidiest to me.

This is an alternative to #113087

I'm not sure why those other cards didn't use statsPeriodStart, maybe it wasn't available at the time, or the engineer didn't know about it?

…ueries

Replace absolute start/end date computation via parseStatsPeriod with
relative statsPeriodStart/statsPeriodEnd params in the velocity and ANR
score cards, matching the pattern already used by the stability card.
This also removes a stray console.log from the velocity card and an
unused parseStatsPeriod import from the apdex card.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 15, 2026
@gggritso gggritso requested a review from a team April 15, 2026 20:10
…d params

Update mock matchers and assertions to expect statsPeriodStart/statsPeriodEnd
instead of absolute start/end dates, matching the implementation change.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gggritso gggritso marked this pull request as ready for review April 15, 2026 20:47
@gggritso gggritso merged commit d164379 into master Apr 15, 2026
63 checks passed
@gggritso gggritso deleted the gg/stability-project-card-query-keys branch April 15, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants