Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Job Queues
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Go
Services
Job Queues
Commits
76cb1ad6
Verified
Commit
76cb1ad6
authored
11 months ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: update statistic
#69
parent
30a97041
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
database.go
+19
-6
19 additions, 6 deletions
database.go
with
19 additions
and
6 deletions
database.go
+
19
−
6
View file @
76cb1ad6
...
...
@@ -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
})
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment