aboutsummaryrefslogtreecommitdiffstats
path: root/modules/convert/issue.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/convert/issue.go')
-rw-r--r--modules/convert/issue.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/convert/issue.go b/modules/convert/issue.go
index d0985b6be1..ab1f9f1e63 100644
--- a/modules/convert/issue.go
+++ b/modules/convert/issue.go
@@ -56,7 +56,7 @@ func ToAPIIssue(issue *models.Issue) *api.Issue {
return &api.Issue{}
}
if issue.Milestone != nil {
- apiIssue.Milestone = issue.Milestone.APIFormat()
+ apiIssue.Milestone = ToAPIMilestone(issue.Milestone)
}
if err := issue.LoadAssignees(); err != nil {
@@ -141,3 +141,22 @@ func ToLabelList(labels []*models.Label) []*api.Label {
}
return result
}
+
+// ToAPIMilestone converts Milestone into API Format
+func ToAPIMilestone(m *models.Milestone) *api.Milestone {
+ apiMilestone := &api.Milestone{
+ ID: m.ID,
+ State: m.State(),
+ Title: m.Name,
+ Description: m.Content,
+ OpenIssues: m.NumOpenIssues,
+ ClosedIssues: m.NumClosedIssues,
+ }
+ if m.IsClosed {
+ apiMilestone.Closed = m.ClosedDateUnix.AsTimePtr()
+ }
+ if m.DeadlineUnix.Year() < 9999 {
+ apiMilestone.Deadline = m.DeadlineUnix.AsTimePtr()
+ }
+ return apiMilestone
+}