scoring

package
v1.4.9 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectBest

func SelectBest(
	aiScores map[uuid.UUID]int,
	candidates []Candidate,
	lastByTea map[uuid.UUID]time.Time,
	now time.Time,
) (uuid.UUID, int)

SelectBest selects the best tea according to the scoring rules. Inputs: - aiScores: context-aware scores (0..15) provided by AI per tea ID (weather + day-of-week) - candidates: list of candidates with expiration/name - lastByTea: most recent consumption time per tea ID - now: current time Returns the ID of the best tea and its total score.

func SelectBestWithLogging added in v1.3.3

func SelectBestWithLogging(
	aiScores map[uuid.UUID]int,
	candidates []Candidate,
	lastByTea map[uuid.UUID]time.Time,
	now time.Time,
	logf LogFunc,
) (uuid.UUID, int)

SelectBestWithLogging selects the best tea and emits detailed logs via the provided logf callback. If logf is nil, no logs are emitted. It preserves the same scoring rules as SelectBest and returns the chosen tea ID and its total score.

Types

type Candidate

type Candidate struct {
	ID         uuid.UUID
	Name       string
	Expiration time.Time // earliest expiration among user records for this tea; zero if unknown
}

Candidate represents a tea candidate for Tea of the Day selection. It intentionally contains only the fields required for scoring to avoid importing API model packages and creating cycles.

type LogFunc added in v1.3.3

type LogFunc func(fields map[string]interface{}, msg string)

LogFunc is a lightweight logging callback used by SelectBestWithLogging to avoid bringing a logging dependency into the scoring package. The provided fields map is expected to be safe for read-only use by the callee.

Jump to

Keyboard shortcuts

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