diff options
author | Unknwon <u@gogs.io> | 2015-08-10 00:37:42 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-10 00:37:42 +0800 |
commit | a79586cc545594d8876438e2497c9408945748b2 (patch) | |
tree | 689da38141f2e3dc2b33a15132f5eb3116915b00 /models/issue.go | |
parent | 590c464c56c993c461f10470926a96448f4f7d00 (diff) | |
parent | 8a3ee795d2d069bbb57b3d134367078c8e8391d5 (diff) | |
download | gitea-a79586cc545594d8876438e2497c9408945748b2.tar.gz gitea-a79586cc545594d8876438e2497c9408945748b2.zip |
Merge branch 'develop' of github.com:gogits/gogs into feature/pull_request2
# Conflicts:
# modules/bindata/bindata.go
# public/css/gogs.min.css
# templates/repo/header.tmpl
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/models/issue.go b/models/issue.go index e757af2d80..39969c7194 100644 --- a/models/issue.go +++ b/models/issue.go @@ -658,6 +658,14 @@ type Milestone struct { ClosedDate time.Time } +func (m *Milestone) BeforeUpdate() { + if m.NumIssues > 0 { + m.Completeness = m.NumClosedIssues * 100 / m.NumIssues + } else { + m.Completeness = 0 + } +} + func (m *Milestone) AfterSet(colName string, _ xorm.Cell) { if colName == "deadline" { if m.Deadline.Year() == 9999 { @@ -804,8 +812,6 @@ func ChangeMilestoneIssueStats(issue *Issue) error { m.NumClosedIssues-- } - m.Completeness = m.NumClosedIssues * 100 / m.NumIssues - return UpdateMilestone(m) } @@ -827,13 +833,8 @@ func ChangeMilestoneAssign(oldMid, mid int64, issue *Issue) (err error) { if issue.IsClosed { m.NumClosedIssues-- } - if m.NumIssues > 0 { - m.Completeness = m.NumClosedIssues * 100 / m.NumIssues - } else { - m.Completeness = 0 - } - if _, err = sess.Id(m.ID).Cols("num_issues,num_completeness,num_closed_issues").Update(m); err != nil { + if _, err = sess.Id(m.ID).AllCols().Update(m); err != nil { sess.Rollback() return err } @@ -860,8 +861,7 @@ func ChangeMilestoneAssign(oldMid, mid int64, issue *Issue) (err error) { return ErrWrongIssueCounter } - m.Completeness = m.NumClosedIssues * 100 / m.NumIssues - if _, err = sess.Id(m.ID).Cols("num_issues,num_completeness,num_closed_issues").Update(m); err != nil { + if _, err = sess.Id(m.ID).AllCols().Update(m); err != nil { sess.Rollback() return err } |