From 1ea1cade8559e1d2aa75916c0dbfe31903423101 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 5 Sep 2020 19:38:54 +0200 Subject: Add Created & Updated to Milestone (#12662) * Add Created and Updated to Milestone table and expose via API * Expose to UI - To Overloaded ?!? * fix unit test Co-authored-by: techknowlogick --- modules/convert/issue.go | 2 ++ modules/convert/issue_test.go | 4 ++++ modules/structs/issue_milestone.go | 4 ++++ 3 files changed, 10 insertions(+) (limited to 'modules') diff --git a/modules/convert/issue.go b/modules/convert/issue.go index a335f6326b..e89021cbcc 100644 --- a/modules/convert/issue.go +++ b/modules/convert/issue.go @@ -152,6 +152,8 @@ func ToAPIMilestone(m *models.Milestone) *api.Milestone { Description: m.Content, OpenIssues: m.NumOpenIssues, ClosedIssues: m.NumClosedIssues, + Created: m.CreatedUnix.AsTime(), + Updated: m.UpdatedUnix.AsTimePtr(), } if m.IsClosed { apiMilestone.Closed = m.ClosedDateUnix.AsTimePtr() diff --git a/modules/convert/issue_test.go b/modules/convert/issue_test.go index e5676293f8..2f8f56e99a 100644 --- a/modules/convert/issue_test.go +++ b/modules/convert/issue_test.go @@ -34,6 +34,8 @@ func TestMilestone_APIFormat(t *testing.T) { IsClosed: false, NumOpenIssues: 5, NumClosedIssues: 6, + CreatedUnix: timeutil.TimeStamp(time.Date(1999, time.January, 1, 0, 0, 0, 0, time.UTC).Unix()), + UpdatedUnix: timeutil.TimeStamp(time.Date(1999, time.March, 1, 0, 0, 0, 0, time.UTC).Unix()), DeadlineUnix: timeutil.TimeStamp(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC).Unix()), } assert.Equal(t, api.Milestone{ @@ -43,6 +45,8 @@ func TestMilestone_APIFormat(t *testing.T) { Description: milestone.Content, OpenIssues: milestone.NumOpenIssues, ClosedIssues: milestone.NumClosedIssues, + Created: milestone.CreatedUnix.AsTime(), + Updated: milestone.UpdatedUnix.AsTimePtr(), Deadline: milestone.DeadlineUnix.AsTimePtr(), }, *ToAPIMilestone(milestone)) } diff --git a/modules/structs/issue_milestone.go b/modules/structs/issue_milestone.go index ec940c2604..ace783ebbc 100644 --- a/modules/structs/issue_milestone.go +++ b/modules/structs/issue_milestone.go @@ -17,6 +17,10 @@ type Milestone struct { OpenIssues int `json:"open_issues"` ClosedIssues int `json:"closed_issues"` // swagger:strfmt date-time + Created time.Time `json:"created_at"` + // swagger:strfmt date-time + Updated *time.Time `json:"updated_at"` + // swagger:strfmt date-time Closed *time.Time `json:"closed_at"` // swagger:strfmt date-time Deadline *time.Time `json:"due_on"` -- cgit v1.2.3