Skip to content

Commit ff44fca

Browse files
committed
apply suggestions from code review
1 parent 759a900 commit ff44fca

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

models/package.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,18 @@ func getPackage(e Engine, repoID int64, typ PackageType, name string) (*Package,
8585
return pkg, nil
8686
}
8787

88-
// UpdateCols updates some columns
89-
func (pkg *Package) UpdateCols(cols ...string) error {
88+
// updateCols updates some columns
89+
func (pkg *Package) updateCols(cols ...string) error {
9090
_, err := x.ID(pkg.ID).Cols(cols...).Update(pkg)
9191
return err
9292
}
9393

94+
// UpdateLastUpdated update last update time
95+
func (pkg *Package) UpdateLastUpdated(updateTime timeutil.TimeStamp) error {
96+
pkg.UpdatedUnix = updateTime
97+
return pkg.updateCols("updated_unix")
98+
}
99+
94100
// LoadRepo load package's repo
95101
func (pkg *Package) LoadRepo(cols ...string) (err error) {
96102
if pkg.Repo != nil {

modules/packages/docker/event_hook.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ func HandleEvents(data *notifications.Envelope) error {
6868
}
6969

7070
// update update time
71-
pkg.UpdatedUnix = timeutil.TimeStamp(event.Timestamp.Unix())
72-
err = pkg.UpdateCols("updated_unix")
71+
err = pkg.UpdateLastUpdated(timeutil.TimeStamp(event.Timestamp.Unix()))
7372
if err != nil {
7473
return err
7574
}

0 commit comments

Comments
 (0)