Skip to content
Snippets Groups Projects
Verified Commit 76cb1ad6 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: update statistic #69

parent 30a97041
No related branches found
No related tags found
No related merge requests found
......@@ -142,12 +142,25 @@ func update(job *JobPersistence, db *gorm.DB) error {
Info("Stats runCount is 0, skipping update")
}
if err := tx.Model(job.Stats).
Select("*").
// 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).
Omit("job_id", "created_at").
Updates(job.Stats).Error; err != nil {
return err // Fehler beim Update
}
FirstOrCreate(&stats)
//if tx.Error != nil {
// return tx.Error
//}
//if err := tx.Model(job.Stats).
// Select("*").
// Omit("job_id", "created_at").
// Updates(job.Stats).Error; err != nil {
// return err // Fehler beim Update
//}
}
for i := range job.Logs {
......@@ -156,7 +169,7 @@ func update(job *JobPersistence, db *gorm.DB) error {
// no error handling, if it fails, it fails
}
return nil
return tx.Error
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment