Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

useFrecencySorting ignores how long ago an item was visited when sorting

Chiusa Adatta ai principianti
#84 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

  • #85 di @auraseb — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Inizia dal comparatore e da getNewFrecency in src/useFrecencySorting.ts; confronta come viene aggiornato il punteggio memorizzato durante le visite e come vengono classificati gli elementi. Verifica la riproduzione minima confrontando un elemento visitato l’ultima volta 60 giorni fa con uno visitato due volte oggi. Il lavoro è completato quando l’ordinamento tiene conto del tempo trascorso e, in questo caso, l’elemento recente è al primo posto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happens

useFrecencySorting stores, for each item, a score and the time of the last visit. When the list is sorted, the stored scores are compared directly:

if (frecencyA && frecencyB) {
  return frecencyB.frecency - frecencyA.frecency;
}

The stored score is only decayed when the same item is visited again (in getNewFrecency). At sort time, a score from a year ago and a score from today are treated as if they were taken at the same moment. As a result:

  1. Two items visited once each always tie at 100, no matter whether the visit was today or a year ago, so the list falls back to the original order.
  2. An item visited 4 times two months ago (stored score 400) stays above an item visited twice today (stored score 200) forever. With the 10 day half life the old score is worth about 6 today.

Once an item has accumulated a high score it can never be overtaken by recent usage of other items unless it is reset.

What should happen

The docs say "The more often an item is visited, and the more recently an item is visited, the higher it will rank." Recent visits should outrank old ones of the same or similar weight, as in the Firefox algorithm the hook is based on.

Minimal repro

// visit "stale" 4 times, then wait 60 days, then visit "fresh" twice
const { data, visitItem } = useFrecencySorting([{ id: "stale" }, { id: "fresh" }]);
// data is [stale, fresh]; expected [fresh, stale]

Root cause

The comparator in src/useFrecencySorting.ts uses frecency without applying the decay for the time elapsed since lastVisited. Decaying both scores to the same now before comparing fixes it. getNewFrecency already has the decay formula, so it can be shared.

Lingua principale
TypeScript
Stelle
85
Fork
19
Merge medio
8m
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di raycast/utils

Tutte le issue di raycast/utils

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.