stats

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 7 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 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 {
	TotalMovies       int64 `json:"total_movies"`
	Monitored         int64 `json:"monitored"`
	WithFile          int64 `json:"with_file"`
	Missing           int64 `json:"missing"`
	NeedsUpgrade      int64 `json:"needs_upgrade"`
	EditionMismatches int64 `json:"edition_mismatches"`
	RecentlyAdded     int64 `json:"recently_added"`
}

CollectionStats is a summary of the movie library.

type DecadeBucket

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

DecadeBucket is a movie count for one decade.

type GenreBucket

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

GenreBucket is a movie 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 is aggregate information about the grab history.

type GrowthPoint

type GrowthPoint struct {
	Month      string `json:"month"`      // "YYYY-MM"
	Added      int64  `json:"added"`      // new movies that month
	Cumulative int64  `json:"cumulative"` // running total
}

GrowthPoint is the number of movies added in a calendar month.

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 per-indexer grab performance.

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 one slice of the quality distribution.

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 properly deduplicated movie count.

type Service

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

Service provides library statistics.

func NewService

func NewService(q dbgen.Querier, cutoff cutoffUnmetLister) *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 movie library.

func (*Service) DecadeDistribution

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

DecadeDistribution returns movie counts grouped by decade.

func (*Service) GenreDistribution

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

GenreDistribution returns the top 15 genres by movie count.

func (*Service) GrabPerformance

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

GrabPerformance returns aggregate grab stats and per-indexer breakdown.

func (*Service) LibraryGrowth

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

LibraryGrowth returns movies-added-per-month with a running cumulative total.

func (*Service) MovieIDsByQualityTier

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

MovieIDsByQualityTier returns movie IDs that have ANY file matching the given resolution and/or source. This is consistent with QualityDistribution which counts every file, not just the best file per movie. Empty filter values match any value.

func (*Service) PruneSnapshots

func (s *Service) PruneSnapshots(ctx context.Context, olderThan time.Duration) error

PruneSnapshots removes snapshots older than the given duration.

func (*Service) QualityDistribution

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

QualityDistribution returns movie file counts grouped by quality dimensions. Quality JSON is decoded in Go to avoid SQLite JSON function limitations.

func (*Service) QualityTiers

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

QualityTiers returns unique movie counts grouped by resolution+source. Each movie is counted once per tier even if it has multiple files at that tier.

func (*Service) Storage

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

Storage returns the current total bytes and file count.

func (*Service) StorageTrend

func (s *Service) StorageTrend(ctx context.Context, limit int) ([]StoragePoint, error)

StorageTrend returns the most recent n storage snapshots, oldest first.

func (*Service) TakeSnapshot

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

TakeSnapshot records the current total storage as a point-in-time snapshot.

type StoragePoint

type StoragePoint struct {
	CapturedAt time.Time `json:"captured_at"`
	TotalBytes int64     `json:"total_bytes"`
	FileCount  int64     `json:"file_count"`
}

StoragePoint is one point in the storage trend history.

type StorageStat

type StorageStat struct {
	TotalBytes int64 `json:"total_bytes"`
	FileCount  int64 `json:"file_count"`
}

StorageStat is the current total storage used by movie files.

Jump to

Keyboard shortcuts

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