summaryrefslogtreecommitdiffstats
path: root/models/issue_watch.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-12-11 12:37:04 +0800
committerLauris BH <lauris@nix.lv>2017-12-11 06:37:04 +0200
commitf2e20c81b66e6a937ecdb686f8d1011371433365 (patch)
tree490e5af82aefdd25de5d90225b083ecb3ed11e5f /models/issue_watch.go
parentc082c3bce35d6d5d829a1e516b9bbf45b6d49bdc (diff)
downloadgitea-f2e20c81b66e6a937ecdb686f8d1011371433365.tar.gz
gitea-f2e20c81b66e6a937ecdb686f8d1011371433365.zip
Refactor struct's time to remove unnecessary memory usage (#3142)
* refactor struct's time to remove unnecessary memory usage * use AsTimePtr simple code * fix tests * fix time compare * fix template on gpg * use AddDuration instead of Add
Diffstat (limited to 'models/issue_watch.go')
-rw-r--r--models/issue_watch.go40
1 files changed, 7 insertions, 33 deletions
diff --git a/models/issue_watch.go b/models/issue_watch.go
index 9ef1ff500f..69e218af01 100644
--- a/models/issue_watch.go
+++ b/models/issue_watch.go
@@ -4,42 +4,16 @@
package models
-import (
- "time"
-)
+import "code.gitea.io/gitea/modules/util"
// IssueWatch is connection request for receiving issue notification.
type IssueWatch struct {
- ID int64 `xorm:"pk autoincr"`
- UserID int64 `xorm:"UNIQUE(watch) NOT NULL"`
- IssueID int64 `xorm:"UNIQUE(watch) NOT NULL"`
- 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() {
- var (
- t = time.Now()
- u = t.Unix()
- )
- iw.Created = t
- iw.CreatedUnix = u
- iw.Updated = t
- iw.UpdatedUnix = u
-}
-
-// BeforeUpdate is invoked from XORM before updating an object of this type.
-func (iw *IssueWatch) BeforeUpdate() {
- var (
- t = time.Now()
- u = t.Unix()
- )
- iw.Updated = t
- iw.UpdatedUnix = u
+ ID int64 `xorm:"pk autoincr"`
+ UserID int64 `xorm:"UNIQUE(watch) NOT NULL"`
+ IssueID int64 `xorm:"UNIQUE(watch) NOT NULL"`
+ IsWatching bool `xorm:"NOT NULL"`
+ CreatedUnix util.TimeStamp `xorm:"created NOT NULL"`
+ UpdatedUnix util.TimeStamp `xorm:"updated NOT NULL"`
}
// CreateOrUpdateIssueWatch set watching for a user and issue