fix job queue

This commit is contained in:
Erik Winter 2024-01-20 13:27:19 +01:00
parent 7ad29cbb46
commit 7a29642bb5
1 changed files with 3 additions and 3 deletions

View File

@ -27,7 +27,7 @@ func (jq *JobQueue) Add(movieID, action string) error {
return errors.New("invalid action") return errors.New("invalid action")
} }
_, err := jq.db.Exec(`INSERT INTO job_queue (movie_id, action, status) _, err := jq.db.Exec(`INSERT INTO job_queue (action_id, action, status)
VALUES (?, ?, 'todo')`, movieID, action) VALUES (?, ?, 'todo')`, movieID, action)
return err return err
@ -42,7 +42,7 @@ func (jq *JobQueue) Next(t Type) (Job, error) {
} }
actionsStr := fmt.Sprintf("('%s')", strings.Join(actions, "', '")) actionsStr := fmt.Sprintf("('%s')", strings.Join(actions, "', '"))
query := fmt.Sprintf(` query := fmt.Sprintf(`
SELECT id, movie_id, action SELECT id, action_id, action
FROM job_queue FROM job_queue
WHERE status='todo' WHERE status='todo'
AND action IN %s AND action IN %s
@ -93,7 +93,7 @@ WHERE id=?`, id); err != nil {
func (jq *JobQueue) List() ([]Job, error) { func (jq *JobQueue) List() ([]Job, error) {
rows, err := jq.db.Query(` rows, err := jq.db.Query(`
SELECT id, movie_id, action, status, created_at, updated_at SELECT id, action_id, action, status, created_at, updated_at
FROM job_queue FROM job_queue
ORDER BY id DESC`) ORDER BY id DESC`)
if err != nil { if err != nil {