Documentation
¶
Overview ¶
Package stats provides library statistics and analytics.
Index ¶
- type CollectionStats
- type DecadeBucket
- type GenreBucket
- type GrabStats
- type GrowthPoint
- type IndexerStat
- type QualityBucket
- type QualityTier
- type Service
- func (s *Service) Collection(ctx context.Context) (CollectionStats, error)
- func (s *Service) DecadeDistribution(ctx context.Context) ([]DecadeBucket, error)
- func (s *Service) GenreDistribution(ctx context.Context) ([]GenreBucket, error)
- func (s *Service) GrabPerformance(ctx context.Context) (GrabStats, []IndexerStat, error)
- func (s *Service) LibraryGrowth(ctx context.Context) ([]GrowthPoint, error)
- func (s *Service) MovieIDsByQualityTier(ctx context.Context, resolution, source string) ([]string, error)
- func (s *Service) PruneSnapshots(ctx context.Context, olderThan time.Duration) error
- func (s *Service) QualityDistribution(ctx context.Context) ([]QualityBucket, error)
- func (s *Service) QualityTiers(ctx context.Context) ([]QualityTier, error)
- func (s *Service) Storage(ctx context.Context) (StorageStat, error)
- func (s *Service) StorageTrend(ctx context.Context, limit int) ([]StoragePoint, error)
- func (s *Service) TakeSnapshot(ctx context.Context) error
- type StoragePoint
- type StorageStat
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
StorageTrend returns the most recent n storage snapshots, oldest first.
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.