From c99c740607672481d75be63f8d200d4c37cc3bca Mon Sep 17 00:00:00 2001
From: Volker Schukai <volker.schukai@schukai.com>
Date: Sat, 4 May 2024 16:40:46 +0200
Subject: [PATCH] fix: init stats (now is a pointer) #64

---
 job.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/job.go b/job.go
index a08d69c..d6082ab 100644
--- a/job.go
+++ b/job.go
@@ -83,6 +83,10 @@ func (j *Job[T]) GetStats() JobStats {
 	j.mu.Lock()
 	defer j.mu.Unlock()
 	// workaround for gorm
+	if j.stats == nil {
+		j.stats = &JobStats{}
+	}
+
 	j.stats.JobID = j.id
 	return *j.stats
 }
@@ -117,7 +121,9 @@ func (j *Job[T]) GetPersistence() JobPersistence {
 		job.Scheduler = j.scheduler.GetPersistence()
 	}
 
-	job.Stats.JobID = job.ID
+	if job.Stats != nil {
+		job.Stats.JobID = job.ID
+	}
 
 	for i := range job.Logs {
 		job.Logs[i].JobID = job.ID
-- 
GitLab