Repository navigation
fix: compute mock activity timestamps at call time, not module load - #742
Open
smartcalsystems-sketch wants to merge 1 commit into
Open
smartcalsystems-sketch wants to merge 1 commit into
smartcalsystems-sketch wants to merge 1 commit into
Conversation
…loses MergeFi#707) recentActivity was a module-level constant, so minutesAgo(n) ran exactly once -- when mock-data.ts was first imported. On a long-running Next.js server the module stays loaded, so a day after deploy the homepage's 'Live on the platform' feed reads '1 day ago' for every event, frozen at whatever moment the process started. Converted recentActivity into getRecentActivity(), a function that builds the array (and calls minutesAgo fresh) on every call. Updated all four consumers (home page, contributor/maintainer/sponsor dashboards) and the test file to call it instead of importing a static array.
|
@smartcalsystems-sketch is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Problem
recentActivityusedminutesAgo(n), computed once whenmock-data.tsis first imported. On a long-lived Next.js server, the module stays loaded, so a day after deploy the homepage's "Live on the platform" feed reads "1 day ago" for every event. #201 replaced literals with this anchoring, which only works for short-lived processes.Fix
Converted the module-level
recentActivityconstant intogetRecentActivity(), a function that builds the array (callingminutesAgofresh) on every call instead of once at import time. Updated all four consumers — the home page, and the contributor/maintainer/sponsor dashboards — to call it at render time instead of importing a frozen array.Testing
occurredAt, advances the clock two simulated days, callsgetRecentActivity()again, and asserts the anchor actually moved forward — this would have failed against the old constant-array version.getRecentActivity().mock-data.test.ts: 7/7 passing.ContributorDashboardClient.test.tsx: 5/5 passing, zero regressions from the import change.tsc --noEmitandeslintclean on all six changed files.Closes #707