trigger endpoint and retry suggestions

This commit is contained in:
2026-04-25 15:21:09 +02:00
parent 20ebe5a49f
commit 846083e230
6 changed files with 103 additions and 37 deletions

View File

@@ -21,6 +21,7 @@ func NewRecommendationsController(mux *http.ServeMux, cfg *configs.Config, rec *
c := &RecommendationsController{cfg: cfg, rec: rec}
mux.HandleFunc("GET /recommendations", c.handleList)
mux.HandleFunc("POST /recommendations/search", c.handleSearch)
mux.HandleFunc("POST /recommendations/trigger", c.handleTrigger)
return c
}
@@ -53,6 +54,21 @@ func (c *RecommendationsController) handleList(w http.ResponseWriter, r *http.Re
httputil.WriteJSON(w, http.StatusOK, recs)
}
// handleTrigger runs the same pipeline as the cron job: recommend + auto-request if Radarr is enabled.
func (c *RecommendationsController) handleTrigger(w http.ResponseWriter, r *http.Request) {
log.Info().Msg("Trigger: running recommendation pipeline")
recs, err := c.rec.Run()
if err != nil {
log.Error().Err(err).Msg("Trigger: pipeline failed")
httputil.WriteError(w, http.StatusInternalServerError, err.Error())
return
}
if c.cfg.RadarrEnabled {
c.rec.AutoRequest(recs)
}
httputil.WriteJSON(w, http.StatusOK, recs)
}
// handleSearch performs a natural-language LLM search and resolves results via TMDb.
// Body: {"query": "sci-fi movies like Blade Runner but more recent"}
func (c *RecommendationsController) handleSearch(w http.ResponseWriter, r *http.Request) {