aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/app/public_json_api.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-04-15 14:16:17 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-04-15 12:52:00 +0000
commitfdcfb1aa92efe1cbbc097e50b0f56b1ca3f7d741 (patch)
tree3ce20a682ea0fb91c96e82d045552e4d1ecad8d0 /dashboard/app/public_json_api.go
parentb9af7e61fec27039b365f0ce8ec03fbccd2c6d6a (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.go43
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),
})
}
}