fix(project-details): Memo the date range#113087
Open
nsdeschenes wants to merge 1 commit intomasterfrom
Open
Conversation
gggritso
added a commit
that referenced
this pull request
Apr 15, 2026
…ueries (#113100) Some of the cards on the Project Details pages cause re-fetch cascades: <img width="799" height="230" alt="Screenshot 2026-04-15 at 4 05 13 PM" src="https://github.com/user-attachments/assets/3fc21cca-5bb5-4f3b-8180-46ae61078d2b" /> <img width="485" height="153" alt="Screenshot 2026-04-15 at 4 06 08 PM" src="https://github.com/user-attachments/assets/ae787bce-6823-47a2-b1b6-b454a15adde6" /> 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? --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wrapping these in
useMemoso it doesn't cause re-renders and fetching sooooo much data.