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 | |
| 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.
| -rw-r--r-- | dashboard/app/getjson_test.go | 26 | ||||
| -rw-r--r-- | dashboard/app/public_json_api.go | 43 |
2 files changed, 47 insertions, 22 deletions
diff --git a/dashboard/app/getjson_test.go b/dashboard/app/getjson_test.go index 03ad24682..ebf943438 100644 --- a/dashboard/app/getjson_test.go +++ b/dashboard/app/getjson_test.go @@ -63,7 +63,24 @@ func TestJSONAPIIntegration(t *testing.T) { sampleFixedBugGroupDescr := []byte(`{ "version": 1, - "Bugs": null + "Bugs": [ + { + "title": "title2", + "link": "/bug?extid=0267d1c87b9ed4eb5def", + "fix-commits": [ + { + "title": "foo: fix1", + "repo": "git://syzkaller.org", + "branch": "branch10" + }, + { + "title": "foo: fix2", + "repo": "git://syzkaller.org", + "branch": "branch10" + } + ] + } + ] }`) c := NewCtx(t) @@ -85,6 +102,13 @@ func TestJSONAPIIntegration(t *testing.T) { checkBugPageJSONIs(c, bugReport2.ID, sampleCrashWithReproDescr) checkBugGroupPageJSONIs(c, "/test1?json=1", sampleOpenBugGroupDescr) + + c.client.ReportingUpdate(&dashapi.BugUpdate{ + ID: bugReport2.ID, + Status: dashapi.BugStatusOpen, + FixCommits: []string{"foo: fix1", "foo: fix2"}, + }) + checkBugGroupPageJSONIs(c, "/test1/fixed?json=1", sampleFixedBugGroupDescr) } 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), }) } } |
