history

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package history manages selection frequency tracking with exponential decay

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type History

type History struct {
	// contains filtered or unexported fields
}

History manages selection frequency tracking

func New

func New(filePath string) *History

New creates a new History instance with the given file path

func (*History) CleanupOldEntries

func (h *History) CleanupOldEntries() int

CleanupOldEntries removes history entries older than maxAgeDays This helps keep the history file size manageable and removes stale data

func (*History) Clear

func (h *History) Clear()

Clear removes all history

func (*History) GetAllScores

func (h *History) GetAllScores() map[string]int

GetAllScores returns a map of all items to their scores with exponential decay

func (*History) GetAllScoresForQuery

func (h *History) GetAllScoresForQuery(query string) map[string]int

GetAllScoresForQuery returns scores for all items, boosted by query-specific history with exponential decay

func (*History) GetScore

func (h *History) GetScore(item string) int

GetScore returns the frequency score for an item with exponential decay Higher score = more frequently selected and more recent Entries older than 100 days return 0

func (*History) GetScoreForQuery

func (h *History) GetScoreForQuery(query, item string) int

GetScoreForQuery returns the score for an item considering query-specific history with exponential decay Query-specific selections get a significant boost (3x multiplier)

func (*History) LoadAsync

func (h *History) LoadAsync() <-chan error

LoadAsync loads history from disk asynchronously Returns a channel that will receive an error (or nil on success)

func (*History) RecordSelection

func (h *History) RecordSelection(item string)

RecordSelection records a selection of the given item

func (*History) RecordSelectionWithQuery

func (h *History) RecordSelectionWithQuery(query, item string)

RecordSelectionWithQuery records a selection with query context

func (*History) Save

func (h *History) Save() error

Save saves the history to disk

func (*History) Stats

func (h *History) Stats() (totalSelections int, uniqueItems int)

Stats returns statistics about the history

type SelectionInfo

type SelectionInfo struct {
	LastUsed time.Time // Last time selected
	Count    int       // Number of times selected
}

SelectionInfo tracks information about a selected item

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL