gitfut icon indicating copy to clipboard operation
gitfut copied to clipboard

Add a way to force-refresh a card (2h cache feels too long after profile changes)

Open afterglow1251 opened this issue 3 months ago • 0 comments

What's the idea

A "re-scout" action that rebuilds a card immediately instead of waiting for the 2h Redis TTL to expire.

Problem it solves

Today I enabled "Private contributions" on my GitHub profile and my card kept showing the old (much lower) numbers — turned out the card is cached for up to 2 hours in lib/scout.ts. There's no way to see fresh stats after changing something on GitHub, and the card doesn't even say it's cached.

How it might work

UI: a quiet one-liner under the Scouting Metrics panel, styled like the faint labels:

⏱ Scouted 47 min ago · ↻ Re-scout

While rebuilding it shows "Re-scouting…"; right after a refresh it collapses to "Scouted just now" until the cooldown expires. Needs a builtAt field on the cached card (and a CACHE_VERSION bump).

Server: to keep it abuse-proof (each rebuild costs GitHub API calls from the token pool), gate it with a per-login cooldown in Redis:

SET gitfut:refresh-lock:<login> 1 NX EX 900

Lock free → rebuild and overwrite the cached card; lock held → tell the user to retry in a few minutes. Worst case is one extra rebuild per profile per 15 min.

Happy to send a PR if you're open to it.

afterglow1251 avatar Sep 01 '26 11:09 afterglow1251