cooldown

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CooldownStats

type CooldownStats struct {
	ActiveCooldowns  int64
	ExpiredCooldowns int64
	TotalPlays       int64
	RecentPlays      int64
}

CooldownStats contains cooldown statistics

type Manager

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

Manager handles media cooldown tracking

func NewManager

func NewManager(
	cooldownRepo *repository.CooldownRepository,
	historyRepo *repository.HistoryRepository,
	cfg *config.CooldownConfig,
	logger *slog.Logger,
) *Manager

NewManager creates a new cooldown Manager

func (*Manager) CleanupExpired

func (m *Manager) CleanupExpired(ctx context.Context) (int64, error)

CleanupExpired removes all expired cooldowns

func (*Manager) GetActiveCooldownMediaIDs

func (m *Manager) GetActiveCooldownMediaIDs(ctx context.Context) ([]int64, error)

GetActiveCooldownMediaIDs returns IDs of all media currently on cooldown

func (*Manager) GetActiveCooldowns

func (m *Manager) GetActiveCooldowns(ctx context.Context) ([]models.MediaCooldown, error)

GetActiveCooldowns retrieves all active cooldowns

func (*Manager) GetCooldown

func (m *Manager) GetCooldown(ctx context.Context, mediaID int64) (*models.MediaCooldown, error)

GetCooldown retrieves the cooldown info for a media item

func (*Manager) GetPlayHistory

func (m *Manager) GetPlayHistory(ctx context.Context, opts repository.ListHistoryOptions) ([]models.PlayHistory, error)

GetPlayHistory retrieves play history with filters

func (*Manager) GetStats

func (m *Manager) GetStats(ctx context.Context) (*CooldownStats, error)

GetStats returns cooldown statistics

func (*Manager) IsOnCooldown

func (m *Manager) IsOnCooldown(ctx context.Context, mediaID int64) (bool, error)

IsOnCooldown checks if a media item is currently on cooldown

func (*Manager) RecordPlay

func (m *Manager) RecordPlay(ctx context.Context, media *models.Media, channelID, themeName string) error

RecordPlay records that a media item was played and sets its cooldown

Jump to

Keyboard shortcuts

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