feat(qa): add synthesis conversations with source retention (#52)
This commit is contained in:
@ -16,7 +16,9 @@ import (
|
||||
"github.com/tradarr/backend/internal/models"
|
||||
"github.com/tradarr/backend/internal/scheduler"
|
||||
"github.com/tradarr/backend/internal/scraper"
|
||||
"github.com/tradarr/backend/internal/summaryqa"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Dependencies struct {
|
||||
@ -32,6 +34,8 @@ type Dependencies struct {
|
||||
EnableScheduler bool
|
||||
}
|
||||
type App struct {
|
||||
stopQA context.CancelFunc
|
||||
qaDone chan struct{}
|
||||
Router *gin.Engine
|
||||
scheduler *scheduler.Scheduler
|
||||
}
|
||||
@ -64,6 +68,14 @@ func New(repo *models.Repository, cfg *config.Config, deps Dependencies) *App {
|
||||
if deps.CompanyCatalog != nil {
|
||||
h.SetCompanyCatalog(deps.CompanyCatalog)
|
||||
}
|
||||
return &App{Router: api.SetupRouter(h, cfg.JWTSecret), scheduler: sched}
|
||||
cleanupCtx, stopQA := context.WithCancel(context.Background())
|
||||
qaDone := make(chan struct{})
|
||||
go func() {
|
||||
defer close(qaDone)
|
||||
if repo != nil {
|
||||
summaryqa.RunPurger(cleanupCtx, repo, time.Minute, func() { log.Print("qa_source_cleanup_failed") })
|
||||
}
|
||||
}()
|
||||
return &App{stopQA: stopQA, qaDone: qaDone, Router: api.SetupRouter(h, cfg.JWTSecret), scheduler: sched}
|
||||
}
|
||||
func (a *App) Close() { a.scheduler.Stop() }
|
||||
func (a *App) Close() { a.scheduler.Stop(); a.stopQA(); <-a.qaDone }
|
||||
|
||||
Reference in New Issue
Block a user