diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2019-09-02 16:50:10 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-09-02 16:50:10 +0000 |
commit | 62b001451bd993e365f2e10635c6d3ad669624f3 (patch) | |
tree | 6b06502677e76d6ffce1fad36daebb71d6f979c5 | |
parent | fb63a00ea4df8196b99570c7f5b2e21793813f9e (diff) | |
parent | 526ea7c5b6cfcca1b94bb8a7b826e64d494471ff (diff) | |
download | gitlab-ce-62b001451bd993e365f2e10635c6d3ad669624f3.tar.gz |
Merge branch 'sh-suppress-diverging-count-commits-request' into 'master'
Skip requesting diverging commit counts if no branches are listed
See merge request gitlab-org/gitlab-ce!32496
3 files changed, 23 insertions, 1 deletions
diff --git a/app/assets/javascripts/branches/divergence_graph.js b/app/assets/javascripts/branches/divergence_graph.js index 7dbaf984acf..303735a1807 100644 --- a/app/assets/javascripts/branches/divergence_graph.js +++ b/app/assets/javascripts/branches/divergence_graph.js @@ -25,6 +25,11 @@ export default endpoint => { const names = [...document.querySelectorAll('.js-branch-item')].map( ({ dataset }) => dataset.name, ); + + if (names.length === 0) { + return true; + } + return axios .get(endpoint, { params: { names }, diff --git a/changelogs/unreleased/sh-suppress-diverging-count-commits-request.yml b/changelogs/unreleased/sh-suppress-diverging-count-commits-request.yml new file mode 100644 index 00000000000..68b95ff9318 --- /dev/null +++ b/changelogs/unreleased/sh-suppress-diverging-count-commits-request.yml @@ -0,0 +1,5 @@ +--- +title: Skip requesting diverging commit counts if no branches are listed +merge_request: 32496 +author: +type: performance diff --git a/spec/frontend/branches/divergence_graph_spec.js b/spec/frontend/branches/divergence_graph_spec.js index 8283bc966e4..adf39a2216a 100644 --- a/spec/frontend/branches/divergence_graph_spec.js +++ b/spec/frontend/branches/divergence_graph_spec.js @@ -25,13 +25,25 @@ describe('Divergence graph', () => { mock.restore(); }); - it('calls axos get with list of branch names', () => + it('calls axios get with list of branch names', () => init('/-/diverging_counts').then(() => { expect(axios.get).toHaveBeenCalledWith('/-/diverging_counts', { params: { names: ['master', 'test/hello-world'] }, }); })); + describe('no branches listed', () => { + beforeEach(() => { + document.body.innerHTML = `<div></div>`; + }); + + it('avoids requesting diverging commit counts', () => { + expect(axios.get).not.toHaveBeenCalledWith('/-/diverging_counts'); + + init('/-/diverging_counts'); + }); + }); + it('creates Vue components', () => init('/-/diverging_counts').then(() => { expect(document.querySelector('[data-name="master"]').innerHTML).not.toEqual(''); |