stats

package
v0.100.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package stats aggregates per-user usage statistics from data the app already records (library resume positions, downloads, search history, watchlists). Pure functions over store rows — no DB access of its own, so every aggregation is unit-testable without SQLite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LibraryAgg

type LibraryAgg struct {
	Titles         int            `json:"titles"`
	Completed      int            `json:"completed"`
	InProgress     int            `json:"inProgress"`
	WatchSeconds   float64        `json:"watchSeconds"`   // accumulated playback position (approximation: rewatches don't add)
	ByKind         map[string]int `json:"byKind"`         // "video" | "audio" | "other"
	PlaysByWeekday [7]int         `json:"playsByWeekday"` // 0 = Sunday, local time
	PlaysByHour    [24]int        `json:"playsByHour"`    // local time
	AddedByMonth   []MonthCount   `json:"addedByMonth"`   // last 6 months, chronological
}

LibraryAgg summarizes the user's playback library.

func Aggregate

func Aggregate(entries []library.Entry, now time.Time, loc *time.Location) LibraryAgg

Aggregate folds library entries into the display aggregates. now/loc define the month window and the timezone of the weekday/hour buckets (the container TZ — same convention as the bandwidth windows).

type MonthCount

type MonthCount struct {
	Month string `json:"month"` // "2026-06"
	Count int    `json:"count"`
}

MonthCount is one bar of the additions-per-month series.

Jump to

Keyboard shortcuts

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