Commit 30818f47 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'codeclimate-requests' into 'master'

Makes code quality requests in parallel

Closes #2910

See merge request gitlab-org/gitlab-ee!3033
parents 9363a476 8f3fe6b1
...@@ -111,18 +111,15 @@ export default { ...@@ -111,18 +111,15 @@ export default {
this.isLoading = true; this.isLoading = true;
this.service.fetchCodeclimate(head_path) Promise.all([
.then(resp => resp.json()) this.service.fetchCodeclimate(head_path)
.then((data) => { .then(resp => resp.json()),
this.mr.setCodeclimateHeadMetrics(data); this.service.fetchCodeclimate(base_path)
this.service.fetchCodeclimate(base_path) .then(resp => resp.json()),
.then(response => response.json()) ])
.then(baseData => this.mr.setCodeclimateBaseMetrics(baseData)) .then((values) => {
.then(() => this.mr.compareCodeclimateMetrics()) this.mr.compareCodeclimateMetrics(values[0], values[1]);
.then(() => { this.isLoading = false;
this.isLoading = false;
})
.catch(() => this.handleError());
}) })
.catch(() => this.handleError()); .catch(() => this.handleError());
}, },
......
...@@ -53,24 +53,12 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -53,24 +53,12 @@ export default class MergeRequestStore extends CEMergeRequestStore {
initCodeclimate(data) { initCodeclimate(data) {
this.codeclimate = data.codeclimate; this.codeclimate = data.codeclimate;
this.codeclimateMetrics = { this.codeclimateMetrics = {
headIssues: [],
baseIssues: [],
newIssues: [], newIssues: [],
resolvedIssues: [], resolvedIssues: [],
}; };
} }
setCodeclimateHeadMetrics(data) { compareCodeclimateMetrics(headIssues, baseIssues) {
this.codeclimateMetrics.headIssues = data;
}
setCodeclimateBaseMetrics(data) {
this.codeclimateMetrics.baseIssues = data;
}
compareCodeclimateMetrics() {
const { headIssues, baseIssues } = this.codeclimateMetrics;
this.codeclimateMetrics.newIssues = this.filterByFingerprint(headIssues, baseIssues); this.codeclimateMetrics.newIssues = this.filterByFingerprint(headIssues, baseIssues);
this.codeclimateMetrics.resolvedIssues = this.filterByFingerprint(baseIssues, headIssues); this.codeclimateMetrics.resolvedIssues = this.filterByFingerprint(baseIssues, headIssues);
} }
......
...@@ -54,36 +54,9 @@ describe('MergeRequestStore', () => { ...@@ -54,36 +54,9 @@ describe('MergeRequestStore', () => {
}); });
}); });
describe('setCodeclimateHeadMetrics', () => {
it('should set defaults', () => {
expect(store.codeclimate).toEqual(mockData.codeclimate);
expect(store.codeclimateMetrics).toEqual({
headIssues: [],
baseIssues: [],
newIssues: [],
resolvedIssues: [],
});
});
it('should set the provided head metrics', () => {
store.setCodeclimateHeadMetrics(headIssues);
expect(store.codeclimateMetrics.headIssues).toEqual(headIssues);
});
});
describe('setCodeclimateBaseMetrics', () => {
it('should set the provided base metrics', () => {
store.setCodeclimateBaseMetrics(baseIssues);
expect(store.codeclimateMetrics.baseIssues).toEqual(baseIssues);
});
});
describe('compareCodeclimateMetrics', () => { describe('compareCodeclimateMetrics', () => {
beforeEach(() => { beforeEach(() => {
store.setCodeclimateHeadMetrics(headIssues); store.compareCodeclimateMetrics(headIssues, baseIssues);
store.setCodeclimateBaseMetrics(baseIssues);
store.compareCodeclimateMetrics();
}); });
it('should return the new issues', () => { it('should return the new issues', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment