diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-04-15 14:16:17 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-04-15 12:52:00 +0000 |
| commit | fdcfb1aa92efe1cbbc097e50b0f56b1ca3f7d741 (patch) | |
| tree | 3ce20a682ea0fb91c96e82d045552e4d1ecad8d0 /dashboard/app/public_json_api.go | |
| parent | b9af7e61fec27039b365f0ce8ec03fbccd2c6d6a (diff) | |
dashboard: include fix commits into terminal page JSONs
There's little sense to make users query that information in separate
queries when we already have it available.
Diffstat (limited to 'dashboard/app/public_json_api.go')
| -rw-r--r-- | dashboard/app/public_json_api.go | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/dashboard/app/public_json_api.go b/dashboard/app/public_json_api.go index 159586132..5b9b6605e 100644 --- a/dashboard/app/public_json_api.go +++ b/dashboard/app/public_json_api.go @@ -53,22 +53,7 @@ func getExtAPIDescrForBugPage(bugPage *uiBugPage) *publicAPIBugDescription { } return []string{bugPage.Bug.ExternalLink} }(), - FixCommits: func() []vcsCommit { - if len(bugPage.Bug.Commits) == 0 { - return nil - } - var res []vcsCommit - for _, commit := range bugPage.Bug.Commits { - res = append(res, vcsCommit{ - Title: commit.Title, - Link: commit.Link, - Hash: commit.Hash, - Repo: commit.Repo, - Branch: commit.Branch, - }) - } - return res - }(), + FixCommits: getBugFixCommits(bugPage.Bug), CauseCommit: func() *vcsCommit { if bugPage.BisectCause == nil || bugPage.BisectCause.Commit == nil { return nil @@ -103,15 +88,30 @@ func getExtAPIDescrForBugPage(bugPage *uiBugPage) *publicAPIBugDescription { } } +func getBugFixCommits(bug *uiBug) []vcsCommit { + var res []vcsCommit + for _, commit := range bug.Commits { + res = append(res, vcsCommit{ + Title: commit.Title, + Link: commit.Link, + Hash: commit.Hash, + Repo: commit.Repo, + Branch: commit.Branch, + }) + } + return res +} + type publicAPIBugGroup struct { Version int `json:"version"` Bugs []publicAPIBug } type publicAPIBug struct { - Title string `json:"title,omitempty"` - Link string `json:"link"` - LastUpdated string `json:"last-updated,omitempty"` + Title string `json:"title,omitempty"` + Link string `json:"link"` + LastUpdated string `json:"last-updated,omitempty"` + FixCommits []vcsCommit `json:"fix-commits,omitempty"` } func getExtAPIDescrForBugGroups(bugGroups []*uiBugGroup) *publicAPIBugGroup { @@ -122,8 +122,9 @@ func getExtAPIDescrForBugGroups(bugGroups []*uiBugGroup) *publicAPIBugGroup { for _, group := range bugGroups { for _, bug := range group.Bugs { res = append(res, publicAPIBug{ - Title: bug.Title, - Link: bug.Link, + Title: bug.Title, + Link: bug.Link, + FixCommits: getBugFixCommits(bug), }) } } |
