diff options
author | Andrey Nering <andrey.nering@gmail.com> | 2017-03-29 20:59:28 -0300 |
---|---|---|
committer | Andrey Nering <andrey.nering@gmail.com> | 2017-03-29 20:59:28 -0300 |
commit | cb362513f027ca8e2c53204f5f2ea447ad06bf05 (patch) | |
tree | 15860c289d09e6a5041038affe3a71beb17389c0 /models | |
parent | aa6e949b3de11e675311e54b59e027cd82a230f4 (diff) | |
download | gitea-cb362513f027ca8e2c53204f5f2ea447ad06bf05.tar.gz gitea-cb362513f027ca8e2c53204f5f2ea447ad06bf05.zip |
Add updated_unix column on issue_watch
Diffstat (limited to 'models')
-rw-r--r-- | models/issue_watch.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/models/issue_watch.go b/models/issue_watch.go index 03a677a3a0..1e26509638 100644 --- a/models/issue_watch.go +++ b/models/issue_watch.go @@ -12,12 +12,21 @@ type IssueWatch struct { IsWatching bool `xorm:"NOT NULL"` Created time.Time `xorm:"-"` CreatedUnix int64 `xorm:"NOT NULL"` + Updated time.Time `xorm:"-"` + UpdatedUnix int64 `xorm:"NOT NULL"` } // BeforeInsert is invoked from XORM before inserting an object of this type. func (iw *IssueWatch) BeforeInsert() { iw.Created = time.Now() iw.CreatedUnix = time.Now().Unix() + iw.Updated = time.Now() + iw.UpdatedUnix = time.Now().Unix() +} + +func (iw *IssueWatch) BeforeUpdate() { + iw.Updated = time.Now() + iw.UpdatedUnix = time.Now().Unix() } // CreateOrUpdateIssueWatch set watching for a user and issue @@ -38,7 +47,9 @@ func CreateOrUpdateIssueWatch(userID, issueID int64, isWatching bool) error { return err } } else { - if _, err := x.Table(&IssueWatch{}).Id(iw.ID).Update(map[string]interface{}{"is_watching": isWatching}); err != nil { + iw.IsWatching = isWatching + + if _, err := x.Id(iw.ID).Cols("is_watching", "updated_unix").Update(iw); err != nil { return err } } |