Skip to content

Attention Trends: the window moves every day, so every cached artefact is keyed to a date #644

Description

@ssdavidai

The TRENDS tab computes its window at page load:

const [trendsFrom] = useState(thirteenWeeksAgo);  // today − 91 days
const [trendsTo]   = useState(now);               // today

So the requested window shifts by one day, every day. Two consequences, one already worked around and one still latent.

Worked around (#643). Alfred's read is stored against the exact grain:from:to key and joined by exact match, so a weekly schedule would have written a key matching only one day in seven. The schedule is daily for that reason alone — not because a daily refresh is otherwise wanted. That is a cadence chosen to compensate for an unstable key.

Still latent — timezone. The workflow derives to from workflow.now() (UTC) while the browser derives it from local time. At 04:00 local these agree for most offsets, but not all: at UTC+13, 04:00 local is the previous day in UTC, and the pre-computed read would be keyed one day off and never display. Home is UTC+2 so this does not bite today; it would on a far-east tenant.

The better fix is to stop the window moving: snap it to period boundaries — the last N complete weeks/months/quarters plus the current partial one. That would give a stable key, let the schedule fire on a natural cadence, remove the timezone hazard entirely, and stop the chart shifting subtly between page loads on the same data.

It would also mean the displayed window no longer silently changes underneath a reader comparing two visits.

Not urgent. The current arrangement works on every tenant in the fleet. Filed so the daily cadence is not mistaken for a considered choice about refresh frequency.

Related: #584.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions