Skip to content

fix: compute mock activity timestamps at call time, not module load - #742

Open
smartcalsystems-sketch wants to merge 1 commit into
MergeFi:mainfrom
smartcalsystems-sketch:fix-mockdata-stale-activity-timestamps-707
Open

smartcalsystems-sketch wants to merge 1 commit into
MergeFi:mainfrom
smartcalsystems-sketch:fix-mockdata-stale-activity-timestamps-707

Conversation

@smartcalsystems-sketch

Copy link
Copy Markdown

Problem

recentActivity used minutesAgo(n), computed once when mock-data.ts is 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 recentActivity constant into getRecentActivity(), a function that builds the array (calling minutesAgo fresh) 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

  • Added a test that mocks system time, reads the first event's occurredAt, advances the clock two simulated days, calls getRecentActivity() again, and asserts the anchor actually moved forward — this would have failed against the old constant-array version.
  • Updated the existing asset-coverage/sanity-ceiling tests to call getRecentActivity().
  • Full mock-data.test.ts: 7/7 passing. ContributorDashboardClient.test.tsx: 5/5 passing, zero regressions from the import change.
  • tsc --noEmit and eslint clean on all six changed files.

Closes #707

…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.
@vercel

vercel Bot commented Oct 13, 2026

Copy link
Copy Markdown

@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

No deployments
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.

Mock activity timestamps are anchored at module load, so a long-running server shows the 'live' feed hours or days stale

1 participant