diff --git a/api/worker.go b/api/worker.go index de0f04c..d62ec71 100644 --- a/api/worker.go +++ b/api/worker.go @@ -185,9 +185,15 @@ func (api *WebAPI) WorkerSetPaused(r *Request) { } func (api *WebAPI) GetAllWorkerStats(r *Request) { - stats := api.Database.GetAllWorkerStats() + if stats == nil { + r.OkJson(JsonResponse{ + Ok: false, + }) + return + } + r.OkJson(JsonResponse{ Ok: true, Content: GetAllWorkerStatsResponse{ diff --git a/storage/worker.go b/storage/worker.go index b0c97e9..f6410c0 100644 --- a/storage/worker.go +++ b/storage/worker.go @@ -181,6 +181,9 @@ func (database *Database) GetAllWorkerStats() *[]WorkerStats { FROM worker WHERE closed_task_count>0 LIMIT 50`) handleErr(err) + if err != nil { + return nil + } stats := make([]WorkerStats, 0) for rows.Next() {