func handleGetGroupStatus(w http.ResponseWriter, r *http.Request) {
	groupID := chi.URLParam(r, "groupID")
	if _, err := jobber.Machinery.GetBackend().GetState(groupID); err == redis.ErrNil {
		sendErrorResponse(w, "group not found", http.StatusNotFound)
		return
	}
	res, err := jobber.Machinery.GetBackend().GroupTaskStates(groupID, 0)
	if err != nil {
		sLog.Printf("error fetching group status: %v", err)
		sendErrorResponse(w, "error fetching group status", http.StatusInternalServerError)
		return
	}
	var (
		jobs        = make([]models.JobStatusResp, len(res))
		jobsDone    = 0
		groupFailed = false
	)
	for i, j := range res {
		jobs[i] = models.JobStatusResp{
			JobID:   j.TaskUUID,
			State:   j.State,
			Results: j.Results,
			Error:   j.Error,
		}
		if j.State == tasks.StateSuccess {
			jobsDone++
		} else if j.State == tasks.StateFailure {
			groupFailed = true
		}
	}
	var groupStatus string
	if groupFailed {
		groupStatus = tasks.StateFailure
	} else if len(res) == jobsDone {
		groupStatus = tasks.StateSuccess
	} else {
		groupStatus = tasks.StatePending
	}
	out := models.GroupStatusResp{
		GroupID: groupID,
		State:   groupStatus,
		Jobs:    jobs,
	}
	sendResponse(w, out)
}
handleGetGroupStatus returns the status of a given groupID.
package main
import (
	"encoding/json"
	"fmt"
	"net/http"
	"regexp"
	"strconv"
	"github.com/RichardKnop/machinery/v1/tasks"
	"github.com/go-chi/chi"
	"github.com/gomodule/redigo/redis"
	"github.com/knadh/sql-jobber/models"
)
const groupConcurrency = 5
var regexValidateName, _ = regexp.Compile("(?i)^[a-z0-9-_:]+$")
func handleGetTasksList(w http.ResponseWriter, r *http.Request) {
	if r.URL.Query().Get("sql") == "" {
		sendResponse(w, jobber.Machinery.GetRegisteredTaskNames())
		return
	}
	sendResponse(w, jobber.Tasks)
}
func handleGetJobStatus(w http.ResponseWriter, r *http.Request) {
	jobID := chi.URLParam(r, "jobID")
	out, err := jobber.Machinery.GetBackend().GetState(jobID)
	if err == redis.ErrNil {
		sendErrorResponse(w, "job not found", http.StatusNotFound)
		return
	} else if err != nil {
		sLog.Printf("error fetching job status: %v", err)
		sendErrorResponse(w, "error fetching job status", http.StatusInternalServerError)
		return
	}
	sendResponse(w, models.JobStatusResp{
		JobID:   out.TaskUUID,
		State:   out.State,
		Results: out.Results,
		Error:   out.Error,
	})
}