urgency

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package urgency computes how "stale" a task is from the time it has dwelt in its current pipeline stage, expressed as a 0..1 intensity for colour ramps.

It is intentionally pure: it depends only on the standard library so it can be table-tested in isolation and reused by both the dashboard and the pipeline screen. The mapping from a stage's configured window to a duration, and from a config string to a Curve, lives in internal/config so this package never imports config (avoiding an import cycle).

Index

Constants

View Source
const (
	EasingLinear       = "linear"
	EasingEaseIn       = "ease-in"
	EasingEaseInStrong = "ease-in-strong"
)

Easing names accepted in team config (dashboard.urgency.easing).

Variables

This section is empty.

Functions

func Ease

func Ease(r float64, curve Curve) float64

Ease shapes a raw fraction r into a display intensity using curve. All curves satisfy Ease(0)=0 and Ease(1)=1 and are monotonic non-decreasing in r; the eased curves are convex (gentle early, sharp late). For equal r the ordering is EaseInStrong ≤ EaseIn ≤ Linear.

func EasingNames

func EasingNames() []string

EasingNames lists the recognised easing names in declaration order. Used for lint validation and did-you-mean suggestions.

func Fraction

func Fraction(dwell, window time.Duration) float64

Fraction returns dwell/window clamped to [0,1]. It returns 0 when window is non-positive — a stage with no stale window is never stale.

func Value

func Value(dwell, window time.Duration, curve Curve) float64

Value composes Ease(Fraction(dwell, window), curve) — the eased intensity for a task that has dwelt for dwell against a stale window.

Types

type Curve

type Curve int

Curve selects how the raw dwell fraction is shaped into a display intensity.

const (
	// Linear maps the fraction unchanged (f = r).
	Linear Curve = iota
	// EaseIn keeps the value cool early and intensifies late (f = r²). Default.
	EaseIn
	// EaseInStrong is a more aggressive ease-in (f = r³).
	EaseInStrong
)

func ParseCurve

func ParseCurve(name string) (curve Curve, ok bool)

ParseCurve resolves an easing name to a Curve. An empty string yields the default (EaseIn). ok is false for an unrecognised name, in which case the returned Curve is the default.

Jump to

Keyboard shortcuts

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