mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 20:59:31 +01:00
Add updated_unix column on issue_watch
This commit is contained in:
parent
aa6e949b3d
commit
cb362513f0
1 changed files with 12 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue