Documentation
¶
Index ¶
- type Aggregator
- func (a *Aggregator) Aggregate(results []*models.ScraperResult) (*models.Movie, error)
- func (a *Aggregator) AggregateWithPriority(results []*models.ScraperResult, customPriority []string) (*models.Movie, error)
- func (a *Aggregator) ApplyConfiguredTranslation(movie *models.Movie)
- func (a *Aggregator) GetResolvedPriorities() map[string][]string
- func (a *Aggregator) ReloadGenreReplacements()
- type AggregatorInterface
- type AggregatorOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator combines metadata from multiple scrapers based on priority
func NewWithDatabase ¶
func NewWithDatabase(cfg *config.Config, db *database.DB) *Aggregator
NewWithDatabase creates a new aggregator with database support for genre replacements and actress aliases. This is the production constructor - for testable constructor see NewWithOptions. Refactored in Epic 8 Story 8.2 to wrap NewWithOptions for backward compatibility.
func NewWithOptions ¶
func NewWithOptions(cfg *config.Config, opts *AggregatorOptions) *Aggregator
NewWithOptions creates a new aggregator with optional dependency injection. If opts is nil or opts fields are nil, real implementations are created or database loading is skipped. If opts fields are non-nil, injected dependencies are used (for testing). Added in Epic 8 Story 8.2 to enable testable aggregator initialization.
Production usage: Use NewWithDatabase() instead Test usage: aggregator.NewWithOptions(cfg, &AggregatorOptions{GenreCache: mockCache})
func (*Aggregator) Aggregate ¶
func (a *Aggregator) Aggregate(results []*models.ScraperResult) (*models.Movie, error)
Aggregate combines multiple scraper results into a single Movie
func (*Aggregator) AggregateWithPriority ¶
func (a *Aggregator) AggregateWithPriority(results []*models.ScraperResult, customPriority []string) (*models.Movie, error)
AggregateWithPriority aggregates results using a custom scraper priority order This is used for manual scraping where users specify which scrapers to use and in what order
func (*Aggregator) ApplyConfiguredTranslation ¶
func (a *Aggregator) ApplyConfiguredTranslation(movie *models.Movie)
func (*Aggregator) GetResolvedPriorities ¶
func (a *Aggregator) GetResolvedPriorities() map[string][]string
GetResolvedPriorities returns the cached field-level priority map (for debugging) Implements AggregatorInterface
func (*Aggregator) ReloadGenreReplacements ¶
func (a *Aggregator) ReloadGenreReplacements()
ReloadGenreReplacements reloads the genre replacement cache from database
type AggregatorInterface ¶
type AggregatorInterface interface {
// Aggregate merges multiple scraper results into a single Movie based on field-level priorities
Aggregate(results []*models.ScraperResult) (*models.Movie, error)
// AggregateWithPriority aggregates results using a custom scraper priority order
AggregateWithPriority(results []*models.ScraperResult, customPriority []string) (*models.Movie, error)
// GetResolvedPriorities returns the cached field-level priority map (for debugging)
GetResolvedPriorities() map[string][]string
}
AggregatorInterface abstracts aggregator operations for dependency injection. Allows CLI commands and API endpoints to accept either real Aggregator or test mocks. Added in Epic 8 Story 8.2 to enable testable aggregation logic.
type AggregatorOptions ¶
type AggregatorOptions struct {
// GenreReplacementRepo is an optional genre replacement repository for tests.
// If nil, loadGenreReplacementCache() is skipped (empty cache).
// If non-nil, genre replacements are loaded from the repository during initialization.
GenreReplacementRepo database.GenreReplacementRepositoryInterface
// ActressAliasRepo is an optional actress alias repository for tests.
// If nil, loadActressAliasCache() is skipped (empty cache).
// If non-nil, actress aliases are loaded from the repository during initialization.
ActressAliasRepo database.ActressAliasRepositoryInterface
// TemplateEngine is an optional template engine for tests.
// If nil, a real template.NewEngine() is created.
// If non-nil, the injected template engine is used.
TemplateEngine *template.Engine
// GenreCache is an optional pre-populated genre replacement cache for tests.
// If non-nil, this cache is used directly without loading from database.
// Takes precedence over GenreReplacementRepo if both are provided.
GenreCache map[string]string
// ActressCache is an optional pre-populated actress alias cache for tests.
// If non-nil, this cache is used directly without loading from database.
// Takes precedence over ActressAliasRepo if both are provided.
ActressCache map[string]string
// Scrapers is an optional list of scrapers for dependency injection.
// If non-nil, the scrapers are used in order as their priority for aggregation.
// If nil, scraperutil.GetPriorities() is used for backward compatibility.
Scrapers []models.Scraper
}
AggregatorOptions allows optional dependency injection for testing. Fields left nil will be initialized with real implementations or skipped entirely. Added in Epic 8 Story 8.2 to support testable aggregator initialization.