forked from gitea/gitea
Remove redundant Unix timestamp method call
Unix() already uses UTC as timezone
This commit is contained in:
parent
4e822c1911
commit
250be011c7
|
@ -89,7 +89,7 @@ type Action struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Action) BeforeInsert() {
|
func (a *Action) BeforeInsert() {
|
||||||
a.CreatedUnix = time.Now().UTC().Unix()
|
a.CreatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Action) AfterSet(colName string, _ xorm.Cell) {
|
func (a *Action) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ type Notice struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Notice) BeforeInsert() {
|
func (n *Notice) BeforeInsert() {
|
||||||
n.CreatedUnix = time.Now().UTC().Unix()
|
n.CreatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Notice) AfterSet(colName string, _ xorm.Cell) {
|
func (n *Notice) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -64,13 +64,13 @@ type Issue struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Issue) BeforeInsert() {
|
func (i *Issue) BeforeInsert() {
|
||||||
i.CreatedUnix = time.Now().UTC().Unix()
|
i.CreatedUnix = time.Now().Unix()
|
||||||
i.UpdatedUnix = i.CreatedUnix
|
i.UpdatedUnix = i.CreatedUnix
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Issue) BeforeUpdate() {
|
func (i *Issue) BeforeUpdate() {
|
||||||
i.UpdatedUnix = time.Now().UTC().Unix()
|
i.UpdatedUnix = time.Now().Unix()
|
||||||
i.DeadlineUnix = i.Deadline.UTC().Unix()
|
i.DeadlineUnix = i.Deadline.Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (issue *Issue) loadAttributes(e Engine) (err error) {
|
func (issue *Issue) loadAttributes(e Engine) (err error) {
|
||||||
|
@ -1046,7 +1046,7 @@ type Milestone struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Milestone) BeforeInsert() {
|
func (m *Milestone) BeforeInsert() {
|
||||||
m.DeadlineUnix = m.Deadline.UTC().Unix()
|
m.DeadlineUnix = m.Deadline.Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Milestone) BeforeUpdate() {
|
func (m *Milestone) BeforeUpdate() {
|
||||||
|
@ -1056,8 +1056,8 @@ func (m *Milestone) BeforeUpdate() {
|
||||||
m.Completeness = 0
|
m.Completeness = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
m.DeadlineUnix = m.Deadline.UTC().Unix()
|
m.DeadlineUnix = m.Deadline.Unix()
|
||||||
m.ClosedDateUnix = m.ClosedDate.UTC().Unix()
|
m.ClosedDateUnix = m.ClosedDate.Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Milestone) AfterSet(colName string, _ xorm.Cell) {
|
func (m *Milestone) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
@ -1361,7 +1361,7 @@ type Attachment struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Attachment) BeforeInsert() {
|
func (a *Attachment) BeforeInsert() {
|
||||||
a.CreatedUnix = time.Now().UTC().Unix()
|
a.CreatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Attachment) AfterSet(colName string, _ xorm.Cell) {
|
func (a *Attachment) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ type Comment struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Comment) BeforeInsert() {
|
func (c *Comment) BeforeInsert() {
|
||||||
c.CreatedUnix = time.Now().UTC().Unix()
|
c.CreatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
|
func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -120,12 +120,12 @@ type LoginSource struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LoginSource) BeforeInsert() {
|
func (s *LoginSource) BeforeInsert() {
|
||||||
s.CreatedUnix = time.Now().UTC().Unix()
|
s.CreatedUnix = time.Now().Unix()
|
||||||
s.UpdatedUnix = s.CreatedUnix
|
s.UpdatedUnix = s.CreatedUnix
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *LoginSource) BeforeUpdate() {
|
func (s *LoginSource) BeforeUpdate() {
|
||||||
s.UpdatedUnix = time.Now().UTC().Unix()
|
s.UpdatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cell2Int64 converts a xorm.Cell type to int64,
|
// Cell2Int64 converts a xorm.Cell type to int64,
|
||||||
|
|
|
@ -646,17 +646,17 @@ func convertDateToUnix(x *xorm.Engine) (err error) {
|
||||||
if bean.Deadline.IsZero() {
|
if bean.Deadline.IsZero() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fieldSQL += com.ToStr(bean.Deadline.UTC().Unix())
|
fieldSQL += com.ToStr(bean.Deadline.Unix())
|
||||||
case "created":
|
case "created":
|
||||||
fieldSQL += com.ToStr(bean.Created.UTC().Unix())
|
fieldSQL += com.ToStr(bean.Created.Unix())
|
||||||
case "updated":
|
case "updated":
|
||||||
fieldSQL += com.ToStr(bean.Updated.UTC().Unix())
|
fieldSQL += com.ToStr(bean.Updated.Unix())
|
||||||
case "closed_date":
|
case "closed_date":
|
||||||
fieldSQL += com.ToStr(bean.ClosedDate.UTC().Unix())
|
fieldSQL += com.ToStr(bean.ClosedDate.Unix())
|
||||||
case "merged":
|
case "merged":
|
||||||
fieldSQL += com.ToStr(bean.Merged.UTC().Unix())
|
fieldSQL += com.ToStr(bean.Merged.Unix())
|
||||||
case "next_update":
|
case "next_update":
|
||||||
fieldSQL += com.ToStr(bean.NextUpdate.UTC().Unix())
|
fieldSQL += com.ToStr(bean.NextUpdate.Unix())
|
||||||
}
|
}
|
||||||
|
|
||||||
valSQLs = append(valSQLs, fieldSQL)
|
valSQLs = append(valSQLs, fieldSQL)
|
||||||
|
|
|
@ -65,7 +65,7 @@ type PullRequest struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *PullRequest) BeforeUpdate() {
|
func (pr *PullRequest) BeforeUpdate() {
|
||||||
pr.MergedUnix = pr.Merged.UTC().Unix()
|
pr.MergedUnix = pr.Merged.Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: don't try to get Pull because will end up recursive querying.
|
// Note: don't try to get Pull because will end up recursive querying.
|
||||||
|
|
|
@ -39,7 +39,7 @@ type Release struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Release) BeforeInsert() {
|
func (r *Release) BeforeInsert() {
|
||||||
r.CreatedUnix = time.Now().UTC().Unix()
|
r.CreatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Release) AfterSet(colName string, _ xorm.Cell) {
|
func (r *Release) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -184,12 +184,12 @@ type Repository struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) BeforeInsert() {
|
func (repo *Repository) BeforeInsert() {
|
||||||
repo.CreatedUnix = time.Now().UTC().Unix()
|
repo.CreatedUnix = time.Now().Unix()
|
||||||
repo.UpdatedUnix = repo.CreatedUnix
|
repo.UpdatedUnix = repo.CreatedUnix
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) BeforeUpdate() {
|
func (repo *Repository) BeforeUpdate() {
|
||||||
repo.UpdatedUnix = time.Now().UTC().Unix()
|
repo.UpdatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) AfterSet(colName string, _ xorm.Cell) {
|
func (repo *Repository) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
@ -533,12 +533,12 @@ type Mirror struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mirror) BeforeInsert() {
|
func (m *Mirror) BeforeInsert() {
|
||||||
m.NextUpdateUnix = m.NextUpdate.UTC().Unix()
|
m.NextUpdateUnix = m.NextUpdate.Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mirror) BeforeUpdate() {
|
func (m *Mirror) BeforeUpdate() {
|
||||||
m.UpdatedUnix = time.Now().UTC().Unix()
|
m.UpdatedUnix = time.Now().Unix()
|
||||||
m.NextUpdateUnix = m.NextUpdate.UTC().Unix()
|
m.NextUpdateUnix = m.NextUpdate.Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Mirror) AfterSet(colName string, _ xorm.Cell) {
|
func (m *Mirror) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -62,11 +62,11 @@ type PublicKey struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *PublicKey) BeforeInsert() {
|
func (k *PublicKey) BeforeInsert() {
|
||||||
k.CreatedUnix = time.Now().UTC().Unix()
|
k.CreatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *PublicKey) BeforeUpdate() {
|
func (k *PublicKey) BeforeUpdate() {
|
||||||
k.UpdatedUnix = time.Now().UTC().Unix()
|
k.UpdatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *PublicKey) AfterSet(colName string, _ xorm.Cell) {
|
func (k *PublicKey) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
@ -638,11 +638,11 @@ type DeployKey struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *DeployKey) BeforeInsert() {
|
func (k *DeployKey) BeforeInsert() {
|
||||||
k.CreatedUnix = time.Now().UTC().Unix()
|
k.CreatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *DeployKey) BeforeUpdate() {
|
func (k *DeployKey) BeforeUpdate() {
|
||||||
k.UpdatedUnix = time.Now().UTC().Unix()
|
k.UpdatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *DeployKey) AfterSet(colName string, _ xorm.Cell) {
|
func (k *DeployKey) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -29,11 +29,11 @@ type AccessToken struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *AccessToken) BeforeInsert() {
|
func (t *AccessToken) BeforeInsert() {
|
||||||
t.CreatedUnix = time.Now().UTC().Unix()
|
t.CreatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *AccessToken) BeforeUpdate() {
|
func (t *AccessToken) BeforeUpdate() {
|
||||||
t.UpdatedUnix = time.Now().UTC().Unix()
|
t.UpdatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *AccessToken) AfterSet(colName string, _ xorm.Cell) {
|
func (t *AccessToken) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -108,7 +108,7 @@ type User struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) BeforeInsert() {
|
func (u *User) BeforeInsert() {
|
||||||
u.CreatedUnix = time.Now().UTC().Unix()
|
u.CreatedUnix = time.Now().Unix()
|
||||||
u.UpdatedUnix = u.CreatedUnix
|
u.UpdatedUnix = u.CreatedUnix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ func (u *User) BeforeUpdate() {
|
||||||
if u.MaxRepoCreation < -1 {
|
if u.MaxRepoCreation < -1 {
|
||||||
u.MaxRepoCreation = -1
|
u.MaxRepoCreation = -1
|
||||||
}
|
}
|
||||||
u.UpdatedUnix = time.Now().UTC().Unix()
|
u.UpdatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) AfterSet(colName string, _ xorm.Cell) {
|
func (u *User) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
|
|
@ -102,12 +102,12 @@ type Webhook struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Webhook) BeforeInsert() {
|
func (w *Webhook) BeforeInsert() {
|
||||||
w.CreatedUnix = time.Now().UTC().Unix()
|
w.CreatedUnix = time.Now().Unix()
|
||||||
w.UpdatedUnix = w.CreatedUnix
|
w.UpdatedUnix = w.CreatedUnix
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Webhook) BeforeUpdate() {
|
func (w *Webhook) BeforeUpdate() {
|
||||||
w.UpdatedUnix = time.Now().UTC().Unix()
|
w.UpdatedUnix = time.Now().Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Webhook) AfterSet(colName string, _ xorm.Cell) {
|
func (w *Webhook) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
@ -239,7 +239,7 @@ func deleteWebhook(bean *Webhook) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteWebhookByRepoID deletes webhook of repository by given ID.
|
// DeleteWebhookByRepoID deletes webhook of repository by given ID.
|
||||||
func DeleteWebhookByRepoID(repoID, id int64) (error) {
|
func DeleteWebhookByRepoID(repoID, id int64) error {
|
||||||
return deleteWebhook(&Webhook{
|
return deleteWebhook(&Webhook{
|
||||||
ID: id,
|
ID: id,
|
||||||
RepoID: repoID,
|
RepoID: repoID,
|
||||||
|
@ -247,7 +247,7 @@ func DeleteWebhookByRepoID(repoID, id int64) (error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteWebhookByOrgID deletes webhook of organization by given ID.
|
// DeleteWebhookByOrgID deletes webhook of organization by given ID.
|
||||||
func DeleteWebhookByOrgID(orgID, id int64) (error) {
|
func DeleteWebhookByOrgID(orgID, id int64) error {
|
||||||
return deleteWebhook(&Webhook{
|
return deleteWebhook(&Webhook{
|
||||||
ID: id,
|
ID: id,
|
||||||
OrgID: orgID,
|
OrgID: orgID,
|
||||||
|
@ -573,7 +573,7 @@ func (t *HookTask) deliver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
t.Delivered = time.Now().UTC().UnixNano()
|
t.Delivered = time.Now().UnixNano()
|
||||||
if t.IsSucceed {
|
if t.IsSucceed {
|
||||||
log.Trace("Hook delivered: %s", t.UUID)
|
log.Trace("Hook delivered: %s", t.UUID)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue