diff options
author | Unknwon <u@gogs.io> | 2015-08-09 22:45:38 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-09 22:45:38 +0800 |
commit | 7372042441804370ddcdf00c5ea29acedef99e1d (patch) | |
tree | 1d7765f3d4b4a22393e2575d78d3bf3d250f800c /models | |
parent | 68b9d78386f74e14841ddc20df110591ac7fba23 (diff) | |
download | gitea-7372042441804370ddcdf00c5ea29acedef99e1d.tar.gz gitea-7372042441804370ddcdf00c5ea29acedef99e1d.zip |
list view: issue, label, milestone
Diffstat (limited to 'models')
-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 d423f05622..1e528d86ae 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 } |