Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • oss/libraries/go/services/job-queues
1 result
Select Git revision
Show changes
Commits on Source (2)
...@@ -142,12 +142,18 @@ func update(job *JobPersistence, db *gorm.DB) error { ...@@ -142,12 +142,18 @@ func update(job *JobPersistence, db *gorm.DB) error {
Info("Stats runCount is 0, skipping update") Info("Stats runCount is 0, skipping update")
} }
if err := tx.Model(job.Stats). // if jobs.Stats not exists in database
// create new record
// else update existing record
var stats JobStats
tx.Model(job.Stats).Where("job_id = ?", job.ID).
Assign(job.Stats).
FirstOrCreate(&stats)
tx.Model(job.Stats).
Select("*"). Select("*").
Omit("job_id", "created_at"). Omit("job_id", "created_at").
Updates(job.Stats).Error; err != nil { Updates(job.Stats)
return err // Fehler beim Update
}
} }
for i := range job.Logs { for i := range job.Logs {
...@@ -156,7 +162,7 @@ func update(job *JobPersistence, db *gorm.DB) error { ...@@ -156,7 +162,7 @@ func update(job *JobPersistence, db *gorm.DB) error {
// no error handling, if it fails, it fails // no error handling, if it fails, it fails
} }
return nil return tx.Error
}) })
} }
......
...@@ -249,7 +249,9 @@ func (m *Manager) ResetJobStats(id JobID) error { ...@@ -249,7 +249,9 @@ func (m *Manager) ResetJobStats(id JobID) error {
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() defer m.mu.Unlock()
if _, ok := m.activeJobs[id]; !ok { if job, ok := m.activeJobs[id]; ok {
job.ResetStats()
} else {
return ErrJobNotActive return ErrJobNotActive
} }
......