overview

package
v0.154.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package overview builds the dashboard statistics wall (gofer-yelm, design docs/design/2026-10-09-dashboard-redesign-design.md): GET /v1/stats/overview folds the jobs that ENDED inside a range (plus their job_metrics rows), the reviews, the plans and the terminal-session usage into one payload, and caches it per (range, tz).

The httpapi layer binds / validates and forwards here (G021); the SQL reads live in jobstore (stats_overview.go). Every metric without a real source is nil on the wire (the page shows 「—」), never a made-up zero.

Index

Constants

View Source
const (
	RangeToday = "today"
	Range7d    = "7d"
	Range30d   = "30d"
	RangeAll   = "all"
)

Range keys. RangeToday is the viewer-local day so far (00:00 in tz .. now).

View Source
const (
	TTL     = 60 * time.Second
	TTLAll  = 5 * time.Minute
	MinHold = 10 * time.Second
)

Cache policy (design §关键流程 缓存): an entry is served while it is younger than its TTL AND the store's stats generation has not moved since it was built; a moved generation still keeps the entry for MinHold, so a burst of ending jobs does not rebuild the overview on every poll.

Variables

View Source
var ErrInvalidQuery = errors.New("invalid overview query")

ErrInvalidQuery marks a bad range / tz.

Functions

This section is empty.

Types

type AgentRow

type AgentRow struct {
	Agent       string   `json:"agent"`
	Jobs        int      `json:"jobs"`
	Done        int      `json:"done"`
	SuccessRate *float64 `json:"success_rate"`
	AvgSec      *int64   `json:"avg_sec"`
}

AgentRow is one agent bar.

type Best

type Best struct {
	Weekday    *BestWeekday `json:"weekday"`
	Day        *BestDay     `json:"day"`
	Month      *BestMonth   `json:"month,omitempty"`
	DailyAvg   *float64     `json:"daily_avg,omitempty"`
	Hour       *BestHour    `json:"hour,omitempty"`
	StreakDays int          `json:"streak_days"`
}

Best is the 最高产 panel. range=today leaves the per-day fields (Weekday / Day / DailyAvg) nil — one partial day has no meaningful 「best day」 — and fills Hour.

type BestDay

type BestDay struct {
	Day  string `json:"day"`
	Done int    `json:"done"`
}

BestDay is the single most productive day.

type BestHour

type BestHour struct {
	Hour int `json:"hour"`
	Done int `json:"done"`
}

BestHour is today's most productive local hour (range=today only).

type BestMonth

type BestMonth struct {
	Month string `json:"month"`
	Done  int    `json:"done"`
}

BestMonth is the most productive month (range=all only).

type BestWeekday

type BestWeekday struct {
	Dow int     `json:"dow"`
	Avg float64 `json:"avg"`
}

BestWeekday: Dow is 0=Sunday … 6=Saturday (JS Date.getDay), Avg the mean done/day.

type DayRow

type DayRow struct {
	Day     string `json:"day"`
	Done    int    `json:"done"`
	Failed  int    `json:"failed"`
	Commits int64  `json:"commits"`
	WallSec int64  `json:"wall_sec"`
}

DayRow is one local day of the range (every day present, zero-filled).

type GitBlock

type GitBlock struct {
	Commits         int64  `json:"commits"`
	JobsWithCommits int    `json:"jobs_with_commits"`
	Files           *int64 `json:"files"`
	Insertions      *int64 `json:"insertions"`
	Deletions       *int64 `json:"deletions"`
	GitJobs         int    `json:"git_jobs"`
}

GitBlock is the Git 活动 card. Commits come from every job's commit list; the line counts only from jobs whose metrics recorded them (GitJobs of them).

type HeatDay

type HeatDay struct {
	Day  string `json:"day"`
	Done int    `json:"done"`
}

HeatDay is one producing day of the heatmap window.

type Heatmap

type Heatmap struct {
	Weeks  int       `json:"weeks"`
	Levels []int     `json:"levels"`
	Days   []HeatDay `json:"days"`
}

Heatmap is the activity grid: Weeks columns ending this week, Days the done count of every producing day in that window, Levels the three thresholds (25th / 50th / 80th percentile of the producing days) that split the four shades.

type HourRow

type HourRow struct {
	Hour    int   `json:"hour"`
	Done    int   `json:"done"`
	Failed  int   `json:"failed"`
	Commits int64 `json:"commits"`
	WallSec int64 `json:"wall_sec"`
}

HourRow is one viewer-local hour of today (range=today only: 24 rows, 0..23, zero-filled, including the hours still ahead). Same metrics as DayRow.

type JobBrief

type JobBrief struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	Agent     string `json:"agent"`
	Project   string `json:"project"`
	Status    string `json:"status"`
	Turns     *int64 `json:"turns"`
	ActiveSec *int64 `json:"active_sec"`
	WallSec   int64  `json:"wall_sec"`
}

JobBrief is one workload row. ActiveSec nil = the job has no metrics row (ranked by its wall time instead).

type JobsBlock

type JobsBlock struct {
	Total       int      `json:"total"`
	Done        int      `json:"done"`
	Failed      int      `json:"failed"`
	Cancelled   int      `json:"cancelled"`
	Rejected    int      `json:"rejected"`
	NeedsReview int      `json:"needs_review"`
	InProgress  int      `json:"in_progress"`
	SuccessRate *float64 `json:"success_rate"`
}

JobsBlock is the Jobs card. Failed folds timeout in; InProgress is a live snapshot (not range-bound). SuccessRate = done / (done + failed + timeout + rejected).

type ModelRow

type ModelRow struct {
	Model           string  `json:"model"`
	Agent           string  `json:"agent,omitempty"`
	Source          string  `json:"source"`
	CostUSD         float64 `json:"cost_usd"`
	InputTokens     int64   `json:"input_tokens"`
	OutputTokens    int64   `json:"output_tokens"`
	CacheReadTokens int64   `json:"cache_read_tokens"`
}

ModelRow is one model's spend. Model "" = the agent's default model (Agent names it); Source is job / session / job+session.

type Overview

type Overview struct {
	Range       RangeInfo    `json:"range"`
	Totals      Totals       `json:"totals"`
	Jobs        JobsBlock    `json:"jobs"`
	Time        TimeBlock    `json:"time"`
	Git         GitBlock     `json:"git"`
	Signal      *SignalBlock `json:"signal"`
	Daily       []DayRow     `json:"daily"`
	Hourly      []HourRow    `json:"hourly,omitempty"`
	Best        Best         `json:"best"`
	Heatmap     Heatmap      `json:"heatmap"`
	Agents      []AgentRow   `json:"agents"`
	Projects    []ProjectRow `json:"projects"`
	Review      ReviewBlock  `json:"review"`
	Workload    Workload     `json:"workload"`
	Usage       *UsageBlock  `json:"usage"`
	Notes       []string     `json:"notes"`
	GeneratedAt int64        `json:"generated_at"`
	Cached      bool         `json:"cached"`
}

Overview is the GET /v1/stats/overview payload.

func Build

func Build(st *jobstore.Store, q Query, now time.Time) (*Overview, error)

Build reads the store and folds one overview (uncached).

type ProjectRow

type ProjectRow struct {
	Project string `json:"project"`
	Jobs    int    `json:"jobs"`
	WallSec int64  `json:"wall_sec"`
	Commits int64  `json:"commits"`
}

ProjectRow is one project (the page ranks the top 3 per column).

type Query

type Query struct {
	// Range is today / 7d / 30d / all ("" = 7d).
	Range string
	// TZMin is the viewer's UTC offset in minutes (east positive: UTC+8 = 480).
	TZMin int
}

Query is the GET /v1/stats/overview input.

func (Query) Normalize

func (q Query) Normalize() (Query, error)

Normalize fills the default range and validates both fields.

type RangeInfo

type RangeInfo struct {
	Key        string `json:"key"`
	From       int64  `json:"from"`
	To         int64  `json:"to"`
	TZ         int    `json:"tz"`
	FirstJobAt int64  `json:"first_job_at"`
}

RangeInfo echoes the resolved window: [From, To) in unix seconds, the tz used, and the first job's start (the 「全部」 origin).

type ReviewBlock

type ReviewBlock struct {
	Reviewed      int      `json:"reviewed"`
	Accepted      int      `json:"accepted"`
	Rejected      int      `json:"rejected"`
	Rerun         int      `json:"rerun"`
	AcceptRate    *float64 `json:"accept_rate"`
	RejectRate    *float64 `json:"reject_rate"`
	WaitAvgSec    *int64   `json:"wait_avg_sec"`
	WaitMedianSec *int64   `json:"wait_median_sec"`
	PendingNow    int      `json:"pending_now"`
	PlansDone     int      `json:"plans_done"`
	TodosDone     int      `json:"todos_done"`
}

ReviewBlock is the 验收与计划 row.

type Service

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

Service serves cached overviews.

func New

func New(st *jobstore.Store) *Service

New builds a Service over the job store.

func (*Service) Get

func (s *Service) Get(q Query) (*Overview, error)

Get returns the overview for q, from the cache when it is still fresh. A served copy carries Cached=true; concurrent misses on one key share a single build.

type SignalBlock

type SignalBlock struct {
	Turns           *int64  `json:"turns"`
	ToolCalls       *int64  `json:"tool_calls"`
	Human           int64   `json:"human"`
	JobsWithHuman   int     `json:"jobs_with_human"`
	DenominatorJobs int     `json:"denominator_jobs"`
	TurnJobs        int     `json:"turn_jobs"`
	ToolJobs        int     `json:"tool_jobs"`
	Coverage        float64 `json:"coverage"`
}

SignalBlock is the 信号 card over the non-exec ended jobs (DenominatorJobs). Turns / ToolCalls sum the jobs that recorded them (TurnJobs / ToolJobs); Coverage is the share of the denominator with a job_metrics row. nil when no such job has a row.

type TimeBlock

type TimeBlock struct {
	WallSec      int64  `json:"wall_sec"`
	AvgSec       *int64 `json:"avg_sec"`
	MedianSec    *int64 `json:"median_sec"`
	ActiveSec    *int64 `json:"active_sec"`
	HumanWaitSec *int64 `json:"human_wait_sec"`
}

TimeBlock is the 耗时 card. Active / human-wait come from job_metrics rows only (nil when none of the range's jobs has one).

type Totals

type Totals struct {
	Jobs     int   `json:"jobs"`
	Sessions int   `json:"sessions"`
	WallSec  int64 `json:"wall_sec"`
}

Totals is the title-line summary.

type UsageBlock

type UsageBlock struct {
	CostUSD         float64    `json:"cost_usd"`
	JobCostUSD      float64    `json:"job_cost_usd"`
	SessionCostUSD  float64    `json:"session_cost_usd"`
	InputTokens     int64      `json:"input_tokens"`
	OutputTokens    int64      `json:"output_tokens"`
	CacheReadTokens int64      `json:"cache_read_tokens"`
	PerTurnUSD      *float64   `json:"per_turn_usd"`
	PerJobUSD       *float64   `json:"per_job_usd"`
	JobsWithUsage   int        `json:"jobs_with_usage"`
	Sessions        int        `json:"sessions"`
	ByModel         []ModelRow `json:"by_model"`
}

UsageBlock is the 用量 section: job + terminal-session spend and tokens. nil when neither side reported anything in the range.

type Workload

type Workload struct {
	Longest  []JobBrief `json:"longest"`
	Quickest []JobBrief `json:"quickest"`
}

Workload is the 耗时分布 pair.

Jump to

Keyboard shortcuts

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