fix
This commit is contained in:
1 parent
feebf7d3c1
commit
486502852e
41 files changed
+1311
-259
No files matched your search
@@ -2,6 +2,7 @@ package httpapi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -41,14 +42,21 @@ func (s *Server) handleStartProcessingJob(w http.ResponseWriter, r *http.Request
|
||||
}
|
||||
ids = append(ids, id)
|
||||
}
|
||||
// Do not schedule jobs with unknown outputs (or create orphaned jobs).
|
||||
for _, requested := range body.ProcessingTypes {
|
||||
if requested != "title" && requested != "description" && requested != "seo_meta" {
|
||||
Error(w, http.StatusBadRequest, fmt.Sprintf("unsupported processing output: %s", requested))
|
||||
return
|
||||
}
|
||||
}
|
||||
// The shared handler serves session dashboard jobs and /api/v1/process.
|
||||
// Public API results should be directly visible in the Processed catalog tab.
|
||||
var jobs []processing.Job
|
||||
var err error
|
||||
if strings.HasPrefix(r.URL.Path, "/api/v1/") {
|
||||
jobs, err = s.Processing.StartAPIJob(r.Context(), cid, uid, ids, body.ProcessingType)
|
||||
jobs, err = s.Processing.StartAPIJobWithTypes(r.Context(), cid, uid, ids, body.ProcessingType, body.ProcessingTypes)
|
||||
} else {
|
||||
jobs, err = s.Processing.StartJob(r.Context(), cid, uid, ids, body.ProcessingType)
|
||||
jobs, err = s.Processing.StartJobWithTypes(r.Context(), cid, uid, ids, body.ProcessingType, body.ProcessingTypes)
|
||||
}
|
||||
if err != nil {
|
||||
if writePlanGate(w, err) {
|
||||
@@ -65,6 +73,7 @@ func (s *Server) handleStartProcessingJob(w http.ResponseWriter, r *http.Request
|
||||
LogAndError(w, http.StatusBadRequest, "could not start processing job", err)
|
||||
return
|
||||
}
|
||||
// Jobs already store the selected outputs transactionally, before enqueueing.
|
||||
for _, job := range jobs {
|
||||
if err := s.Jobs.EnqueueProcessingJob(r.Context(), job.ID); err != nil {
|
||||
Error(w, http.StatusInternalServerError, "enqueue failed")
|
||||
|
||||
Reference in new issue
Block a user