diff options
author | romankl <romankl@users.noreply.github.com> | 2018-12-02 21:43:01 +0100 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2018-12-02 15:43:01 -0500 |
commit | 2d707fe5e663abb0be2127362c760446ce6cedab (patch) | |
tree | a8e1e43319f58501a51d9871508fbf1720066c66 /models | |
parent | ce4885f76179ef694bac0184a0a954b24d4ef5d0 (diff) | |
download | gitea-2d707fe5e663abb0be2127362c760446ce6cedab.tar.gz gitea-2d707fe5e663abb0be2127362c760446ce6cedab.zip |
ensure that the `closed_at` is set for closed (#5449)
right now the `closed_at` field for json responses is not filled during
the `APIIssue` creation for api responses.
For a closed issue you get a result like:
```json
"state":"open","comments":0,"created_at":"2018-11-29T16:39:24+01:00",
"updated_at":"2018-11-30T10:49:19+01:00","closed_at":null,
"due_date":null,"pull_request":null}
```
which has no information about the closing date. (which exists in the
db and ui)
with this PR the result changes to this:
```json
:null,"assignee":null,"assignees":null,
"state":"closed",
"comments":0,"created_at":"2018-11-29T16:43:05+01:00",
"updated_at":"2018-12-02T19:17:05+01:00",
"closed_at":"2018-12-02T19:17:05+01:00",
"due_date":null,"pull_request":null}
```
fixes: https://github.com/go-gitea/gitea/issues/5446
Signed-off-by: Roman <romaaan.git@gmail.com>
Diffstat (limited to 'models')
-rw-r--r-- | models/issue.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/models/issue.go b/models/issue.go index d4222b04a0..88e96e5706 100644 --- a/models/issue.go +++ b/models/issue.go @@ -329,6 +329,10 @@ func (issue *Issue) APIFormat() *api.Issue { Updated: issue.UpdatedUnix.AsTime(), } + if issue.ClosedUnix != 0 { + apiIssue.Closed = issue.ClosedUnix.AsTimePtr() + } + if issue.Milestone != nil { apiIssue.Milestone = issue.Milestone.APIFormat() } |