summaryrefslogtreecommitdiffstats
path: root/modules/convert/issue.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-05-12 23:54:35 +0200
committerGitHub <noreply@github.com>2020-05-12 22:54:35 +0100
commit7257c39ddfe9d9d424192e6bd307a70ed544f5be (patch)
tree67e2fb0861e0b5fe610e424c8b3906db438c6335 /modules/convert/issue.go
parentba40263fdda53446c7cae6e41885ebdee8bb7b52 (diff)
downloadgitea-7257c39ddfe9d9d424192e6bd307a70ed544f5be.tar.gz
gitea-7257c39ddfe9d9d424192e6bd307a70ed544f5be.zip
Refactor Milestone related (#11225)
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
+}