stats

package
v0.0.0-...-d771ed5 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package stats provides library statistics and analytics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectionStats

type CollectionStats struct {
	TotalSeries   int64 `json:"total_series"`
	TotalEpisodes int64 `json:"total_episodes"`
	Monitored     int64 `json:"monitored"`
	WithFile      int64 `json:"with_file"`
	Missing       int64 `json:"missing"`
	NeedsUpgrade  int64 `json:"needs_upgrade"`
	RecentlyAdded int64 `json:"recently_added"` // series added in the last 30 days
}

CollectionStats is a summary of the episode library.

type DecadeBucket

type DecadeBucket struct {
	Decade string `json:"decade"` // e.g. "1990s"
	Count  int64  `json:"count"`
}

DecadeBucket is a series count for one decade.

type GenreBucket

type GenreBucket struct {
	Genre string `json:"genre"`
	Count int64  `json:"count"`
}

GenreBucket is a series count for one genre.

type GrabStats

type GrabStats struct {
	TotalGrabs  int64   `json:"total_grabs"`
	Successful  int64   `json:"successful"`
	Failed      int64   `json:"failed"`
	SuccessRate float64 `json:"success_rate"`
}

GrabStats summarizes overall grab activity.

type GrowthPoint

type GrowthPoint struct {
	SnapshotAt    string `json:"snapshot_at"`
	TotalSeries   int64  `json:"total_series"`
	TotalEpisodes int64  `json:"total_episodes"`
	WithFile      int64  `json:"with_file"`
	TotalBytes    int64  `json:"total_bytes"`
}

GrowthPoint is a point-in-time stats snapshot for trend charts.

type IndexerStat

type IndexerStat struct {
	IndexerID   string  `json:"indexer_id"`
	IndexerName string  `json:"indexer_name"`
	GrabCount   int64   `json:"grab_count"`
	SuccessRate float64 `json:"success_rate"`
}

IndexerStat is one row of the top-indexers list.

type QualityBucket

type QualityBucket struct {
	Resolution string `json:"resolution"`
	Source     string `json:"source"`
	Codec      string `json:"codec"`
	HDR        string `json:"hdr"`
	Count      int64  `json:"count"`
}

QualityBucket is a full quality breakdown (resolution+source+codec+hdr) with a unique-series count. Used by the "By Dimension" view.

type QualityTier

type QualityTier struct {
	Resolution string `json:"resolution"`
	Source     string `json:"source"`
	Count      int64  `json:"count"`
}

QualityTier is a resolution+source group with a unique-series count.

type Service

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

Service provides library statistics.

func NewService

func NewService(q db.Querier) *Service

NewService creates a new statistics Service.

func (*Service) Collection

func (s *Service) Collection(ctx context.Context) (CollectionStats, error)

Collection returns aggregate counts for the episode library.

func (*Service) DecadeDistribution

func (s *Service) DecadeDistribution(ctx context.Context) ([]DecadeBucket, error)

DecadeDistribution returns series counts grouped by decade ("1990s", "2000s", …) in chronological order.

func (*Service) GenreDistribution

func (s *Service) GenreDistribution(ctx context.Context) ([]GenreBucket, error)

GenreDistribution returns the top 15 genres by series count.

func (*Service) GrabPerformance

func (s *Service) GrabPerformance(ctx context.Context) (GrabStats, []IndexerStat, error)

GrabPerformance returns overall grab counts and the top-10 indexers by grab volume. Mirrors prism's same-named endpoint so the dashboard renders identically across pilot and prism.

func (*Service) Growth

func (s *Service) Growth(ctx context.Context) ([]GrowthPoint, error)

Growth returns recent stats snapshots oldest-first for trend charting.

func (*Service) Quality

func (s *Service) Quality(ctx context.Context) ([]QualityBucket, error)

Quality returns unique series counts grouped by the full quality breakdown (resolution+source+codec+hdr). Powers the "By Dimension" view.

func (*Service) QualityTiers

func (s *Service) QualityTiers(ctx context.Context) ([]QualityTier, error)

QualityTiers returns unique series counts grouped by resolution+source. A series with multiple files at the same tier is counted once. Mirrors the bar counts shown on the Stats page and the drilldown result count.

func (*Service) SeriesIDsByQualityTier

func (s *Service) SeriesIDsByQualityTier(ctx context.Context, resolution, source string) ([]string, error)

SeriesIDsByQualityTier returns series IDs that have ANY file matching the given resolution and/or source. Mirrors QualityTiers' bucketing — empty filter values match any value.

func (*Service) Snapshot

func (s *Service) Snapshot(ctx context.Context) error

Snapshot records a point-in-time stats snapshot.

func (*Service) Storage

func (s *Service) Storage(ctx context.Context) (StorageStat, error)

Storage returns the current total bytes and file count from episode_files.

type StoragePoint

type StoragePoint struct {
	CapturedAt string `json:"captured_at"` // RFC3339
	TotalBytes int64  `json:"total_bytes"`
	FileCount  int64  `json:"file_count"`
}

StoragePoint is one historical sample of total storage usage.

type StorageStat

type StorageStat struct {
	TotalBytes int64          `json:"total_bytes"`
	FileCount  int64          `json:"file_count"`
	Trend      []StoragePoint `json:"trend"`
}

StorageStat is the current total storage used by episode files, plus a trend series for the in-card sparkline.

Jump to

Keyboard shortcuts

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