Documentation
¶
Overview ¶
Package frecency provides frequency and recency-based scoring for workflow history.
Index ¶
- func CachePath() string
- func Score(entry HistoryEntry) float64
- func SortByFrecency(entries []HistoryEntry)
- type ChainStepResult
- type EntryType
- type HistoryEntry
- type Store
- func (s *Store) Record(repo, workflow, branch string, inputs map[string]string)
- func (s *Store) RecordChain(repo, chainName, branch string, inputs map[string]string, ...)
- func (s *Store) Save() error
- func (s *Store) SaveTo(path string) error
- func (s *Store) TopForRepo(repo, workflowFilter string, limit int) []HistoryEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CachePath ¶
func CachePath() string
CachePath returns the path to the frecency cache file. Migrates from old gh-wfd directory to lazydispatch if needed.
func Score ¶
func Score(entry HistoryEntry) float64
Score calculates the frecency score for an entry. Higher scores indicate more frequently and recently used entries.
func SortByFrecency ¶
func SortByFrecency(entries []HistoryEntry)
SortByFrecency sorts entries by frecency score in descending order.
Types ¶
type ChainStepResult ¶
type ChainStepResult struct {
Workflow string `json:"workflow"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
RunID int64 `json:"run_id"`
}
ChainStepResult represents the result of a single step in a chain run.
type HistoryEntry ¶
type HistoryEntry struct {
LastRunAt time.Time `json:"last_run_at"`
Inputs map[string]string `json:"inputs"`
Type EntryType `json:"type"`
Workflow string `json:"workflow"`
ChainName string `json:"chain_name,omitempty"`
Branch string `json:"branch"`
StepResults []ChainStepResult `json:"step_results,omitempty"`
RunCount int `json:"run_count"`
}
HistoryEntry represents a single workflow or chain run in history.
func FilterByType ¶
func FilterByType(entries []HistoryEntry, entryType EntryType) []HistoryEntry
FilterByType returns entries matching the given entry type. Empty type "" is treated as workflow for backward compatibility.
func FilterByWorkflow ¶
func FilterByWorkflow(entries []HistoryEntry, workflow string) []HistoryEntry
FilterByWorkflow returns entries matching the given workflow filename. Only filters workflow-type entries (chains are excluded).
type Store ¶
type Store struct {
Entries map[string][]HistoryEntry `json:"entries"`
}
Store holds frecency history keyed by repository (org/repo).
func (*Store) RecordChain ¶
func (s *Store) RecordChain(repo, chainName, branch string, inputs map[string]string, stepResults []ChainStepResult)
RecordChain adds or updates a chain history entry for the given repo.
func (*Store) TopForRepo ¶
func (s *Store) TopForRepo(repo, workflowFilter string, limit int) []HistoryEntry
TopForRepo returns the top entries for a repo, optionally filtered by workflow.