From 4c52858c39f848198a61b27a9a8fe70d12db3b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Villablanca=20V=C3=A1squez?= Date: Tue, 1 Jan 2019 14:56:47 -0300 Subject: [PATCH] Issue is not overdue when it is on the same date #5566 (#5568) * Due date time of issues and milestones is set to 23:59:59 * Add docs * make gen swagger * fix swagger gen --- routers/api/v1/repo/issue.go | 14 +++++++++----- routers/repo/milestone.go | 2 ++ templates/swagger/v1_json.tmpl | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 65c97888f5..fe00715949 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -9,6 +9,7 @@ import ( "fmt" "net/http" "strings" + "time" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" @@ -144,7 +145,7 @@ func GetIssue(ctx *context.APIContext) { func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { // swagger:operation POST /repos/{owner}/{repo}/issues issue issueCreateIssue // --- - // summary: Create an issue + // summary: Create an issue. If using deadline only the date will be taken into account, and time of day ignored. // consumes: // - application/json // produces: @@ -236,7 +237,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { // swagger:operation PATCH /repos/{owner}/{repo}/issues/{index} issue issueEditIssue // --- - // summary: Edit an issue + // summary: Edit an issue. If using deadline only the date will be taken into account, and time of day ignored. // consumes: // - application/json // produces: @@ -360,7 +361,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) { // swagger:operation POST /repos/{owner}/{repo}/issues/{index}/deadline issue issueEditIssueDeadline // --- - // summary: Set an issue deadline. If set to null, the deadline is deleted. + // summary: Set an issue deadline. If set to null, the deadline is deleted. If using deadline only the date will be taken into account, and time of day ignored. // consumes: // - application/json // produces: @@ -410,8 +411,11 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) { } var deadlineUnix util.TimeStamp + var deadline time.Time if form.Deadline != nil && !form.Deadline.IsZero() { - deadlineUnix = util.TimeStamp(form.Deadline.Unix()) + deadline = time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(), + 23, 59, 59, 0, form.Deadline.Location()) + deadlineUnix = util.TimeStamp(deadline.Unix()) } if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil { @@ -419,5 +423,5 @@ func UpdateIssueDeadline(ctx *context.APIContext, form api.EditDeadlineOption) { return } - ctx.JSON(201, api.IssueDeadline{Deadline: form.Deadline}) + ctx.JSON(201, api.IssueDeadline{Deadline: &deadline}) } diff --git a/routers/repo/milestone.go b/routers/repo/milestone.go index eb2141e995..6c3ad11f1f 100644 --- a/routers/repo/milestone.go +++ b/routers/repo/milestone.go @@ -113,6 +113,7 @@ func NewMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) { return } + deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location()) if err = models.NewMilestone(&models.Milestone{ RepoID: ctx.Repo.Repository.ID, Name: form.Title, @@ -175,6 +176,7 @@ func EditMilestonePost(ctx *context.Context, form auth.CreateMilestoneForm) { return } + deadline = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, deadline.Location()) m, err := models.GetMilestoneByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) if err != nil { if models.IsErrMilestoneNotExist(err) { diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index b96a20109c..52633957c3 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -1967,7 +1967,7 @@ "tags": [ "issue" ], - "summary": "Create an issue", + "summary": "Create an issue. If using deadline only the date will be taken into account, and time of day ignored.", "operationId": "issueCreateIssue", "parameters": [ { @@ -2271,7 +2271,7 @@ "tags": [ "issue" ], - "summary": "Edit an issue", + "summary": "Edit an issue. If using deadline only the date will be taken into account, and time of day ignored.", "operationId": "issueEditIssue", "parameters": [ { @@ -2521,7 +2521,7 @@ "tags": [ "issue" ], - "summary": "Set an issue deadline. If set to null, the deadline is deleted.", + "summary": "Set an issue deadline. If set to null, the deadline is deleted. If using deadline only the date will be taken into account, and time of day ignored.", "operationId": "issueEditIssueDeadline", "parameters": [ {