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
This commit is contained in:
Lunny Xiao 2017-12-11 12:37:04 +08:00 committed by Lauris BH
parent c082c3bce3
commit f2e20c81b6
67 changed files with 334 additions and 479 deletions

View file

@ -10,11 +10,11 @@ import (
"mime/multipart"
"os"
"path"
"time"
gouuid "github.com/satori/go.uuid"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
)
// Attachment represent a attachment of issue/comment/release.
@ -25,15 +25,8 @@ type Attachment struct {
ReleaseID int64 `xorm:"INDEX"`
CommentID int64
Name string
DownloadCount int64 `xorm:"DEFAULT 0"`
Created time.Time `xorm:"-"`
CreatedUnix int64 `xorm:"created"`
}
// AfterLoad is invoked from XORM after setting the value of a field of
// this object.
func (a *Attachment) AfterLoad() {
a.Created = time.Unix(a.CreatedUnix, 0).Local()
DownloadCount int64 `xorm:"DEFAULT 0"`
CreatedUnix util.TimeStamp `xorm:"created"`
}
// IncreaseDownloadCount is update download count + 1