summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-08-31 23:04:11 -0700
committerStan Hu <stanhu@gmail.com>2019-09-01 13:41:27 -0700
commitcf401ce93cfddcb9940d28cdf15895cf3d6edf61 (patch)
treefe8acb3535caca2508435686fe75821afec8bcfd
parent7c1c8b8ea03d1a78fc38fe950f020a1e0bd70e85 (diff)
downloadgitlab-ce-sh-suppress-diverging-count-commits-request.tar.gz
Skip requesting diverging commit counts if no branches are listedsh-suppress-diverging-count-commits-request
When a branch list is displayed in the UI, the diverging commit counts are usually displayed for a subset of branches available in the repository to prevent excessive Gitaly calls using the `names` parameter. However, when clicking on the different tabs in the branch controller (e.g. Stale, Active), it's possible the list is empty. Since the names parameter is empty, the backend thinks it should return the counts for ALL branches. We can save considerable I/O in this case by not making the request at all. Part of https://gitlab.com/gitlab-org/gitlab-ce/issues/66200
-rw-r--r--app/assets/javascripts/branches/divergence_graph.js5
-rw-r--r--changelogs/unreleased/sh-suppress-diverging-count-commits-request.yml5
-rw-r--r--package.json2
-rw-r--r--spec/frontend/branches/divergence_graph_spec.js14
-rw-r--r--yarn.lock8
5 files changed, 28 insertions, 6 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/package.json b/package.json
index 4244dc2d52b..3d9e0838893 100644
--- a/package.json
+++ b/package.json
@@ -96,7 +96,7 @@
"jszip-utils": "^0.0.2",
"katex": "^0.10.0",
"marked": "^0.3.12",
- "mermaid": "^8.2.6",
+ "mermaid": "^8.2.4",
"monaco-editor": "^0.15.6",
"monaco-editor-webpack-plugin": "^1.7.0",
"mousetrap": "^1.4.6",
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('');
diff --git a/yarn.lock b/yarn.lock
index 4cf3a9584f1..6ab2aa24685 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8116,10 +8116,10 @@ merge2@^1.2.3:
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.2.3.tgz#7ee99dbd69bb6481689253f018488a1b902b0ed5"
integrity sha512-gdUU1Fwj5ep4kplwcmftruWofEFt6lfpkkr3h860CXbAB9c3hGb55EOL2ali0Td5oebvW0E1+3Sr+Ur7XfKpRA==
-mermaid@^8.2.6:
- version "8.2.6"
- resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-8.2.6.tgz#e73f396461a435c39a998819171c2114f59e46e1"
- integrity sha512-A8y4zW2aXPj8Yw+BkrCkV6fvzhsFWVESV1IkzRjqQ6T/+tzhkz946+bdebCmHqicEJGTncu/U6h8dgjo5pWo6Q==
+mermaid@^8.2.4:
+ version "8.2.4"
+ resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-8.2.4.tgz#52bcd45611fd8552ab9ac4e385d2766a0e38dcf7"
+ integrity sha512-2la1eJhu4n+Uug4zbxFnkETFDJ9U32OY/fRP8g8A1DrRdfT3Er+7CuUSvxfhIDxl+AxSEU4dXdqCiToZAVMCmQ==
dependencies:
"@braintree/sanitize-url" "^3.1.0"
d3 "^5.7.0"