feat(generation): persist summary outcomes without articles
Record generation outcomes and summaries for history while keeping article content transient. Refs #7 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -7,17 +7,22 @@ import (
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/tradarr/backend/internal/ai"
|
||||
"github.com/tradarr/backend/internal/generation"
|
||||
"github.com/tradarr/backend/internal/models"
|
||||
"github.com/tradarr/backend/internal/scraper"
|
||||
)
|
||||
|
||||
type userLister interface{ ListUsers() ([]models.User, error) }
|
||||
|
||||
type Scheduler struct {
|
||||
cron *cron.Cron
|
||||
registry *scraper.Registry
|
||||
pipeline *ai.Pipeline
|
||||
repo *models.Repository
|
||||
entryIDs []cron.EntryID
|
||||
running sync.Mutex
|
||||
users userLister
|
||||
generationUseCase generation.UseCase
|
||||
cron *cron.Cron
|
||||
registry *scraper.Registry
|
||||
pipeline *ai.Pipeline
|
||||
repo *models.Repository
|
||||
entryIDs []cron.EntryID
|
||||
running sync.Mutex
|
||||
}
|
||||
|
||||
func New(registry *scraper.Registry, pipeline *ai.Pipeline, repo *models.Repository) *Scheduler {
|
||||
@ -26,6 +31,7 @@ func New(registry *scraper.Registry, pipeline *ai.Pipeline, repo *models.Reposit
|
||||
registry: registry,
|
||||
pipeline: pipeline,
|
||||
repo: repo,
|
||||
users: repo,
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,14 +97,18 @@ func (s *Scheduler) run() {
|
||||
}
|
||||
}()
|
||||
|
||||
fmt.Println("scheduler: starting scraping cycle")
|
||||
if err := s.registry.RunAll(); err != nil {
|
||||
fmt.Printf("scheduler scrape error: %v\n", err)
|
||||
if s.generationUseCase == nil {
|
||||
return
|
||||
}
|
||||
fmt.Println("scheduler: starting AI summaries")
|
||||
if err := s.pipeline.GenerateForAll(context.Background()); err != nil {
|
||||
fmt.Printf("scheduler summary error: %v\n", err)
|
||||
users, err := s.users.ListUsers()
|
||||
if err != nil {
|
||||
fmt.Println("scheduler: unable to load accounts")
|
||||
return
|
||||
}
|
||||
for _, user := range users {
|
||||
if _, err := s.generationUseCase.Generate(context.Background(), user.ID); err != nil {
|
||||
fmt.Println("scheduler: generation failed")
|
||||
}
|
||||
}
|
||||
fmt.Println("scheduler: cycle complete")
|
||||
}
|
||||
func (s *Scheduler) SetGenerationUseCase(uc generation.UseCase) { s.generationUseCase = uc }
|
||||
|
||||
Reference in New Issue
Block a user