forked from goharbor/harbor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
joblog.go
40 lines (35 loc) · 798 Bytes
/
joblog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package dao
import (
"github.com/astaxie/beego/orm"
"github.com/goharbor/harbor/src/common/models"
"time"
)
// CreateOrUpdateJobLog ...
func CreateOrUpdateJobLog(log *models.JobLog) (int64, error) {
o := GetOrmer()
count, err := o.InsertOrUpdate(log, "job_uuid")
if err != nil {
return 0, err
}
return count, nil
}
// GetJobLog ...
func GetJobLog(uuid string) (*models.JobLog, error) {
o := GetOrmer()
jl := models.JobLog{UUID: uuid}
err := o.Read(&jl, "UUID")
if err == orm.ErrNoRows {
return nil, err
}
return &jl, nil
}
// DeleteJobLogsBefore ...
func DeleteJobLogsBefore(t time.Time) (int64, error) {
o := GetOrmer()
sql := `delete from job_log where creation_time < ?`
res, err := o.Raw(sql, t).Exec()
if err != nil {
return 0, err
}
return res.RowsAffected()
}