Commit f73534ae authored by Clement Ho's avatar Clement Ho

Merge branch 'mfluharty-code-quality-worker-variable-mismatch' into 'master'

Fix variable mismatch in code quality widget

See merge request gitlab-org/gitlab-ee!14829
parents a416bd9d 0263d973
...@@ -96,9 +96,11 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -96,9 +96,11 @@ export default class MergeRequestStore extends CEMergeRequestStore {
static doCodeClimateComparison(headIssues, baseIssues) { static doCodeClimateComparison(headIssues, baseIssues) {
// Do these comparisons in worker threads to avoid blocking the main thread // Do these comparisons in worker threads to avoid blocking the main thread
return new Promise(resolve => { return new Promise((resolve, reject) => {
const worker = new CodeQualityComparisonWorker(); const worker = new CodeQualityComparisonWorker();
worker.addEventListener('message', ({ data }) => resolve(data)); worker.addEventListener('message', ({ data }) =>
data.newIssues && data.resolvedIssues ? resolve(data) : reject(data),
);
worker.postMessage({ worker.postMessage({
headIssues, headIssues,
baseIssues, baseIssues,
......
...@@ -7,15 +7,22 @@ self.addEventListener('message', e => { ...@@ -7,15 +7,22 @@ self.addEventListener('message', e => {
const { data } = e; const { data } = e;
if (data === undefined) { if (data === undefined) {
return; return null;
}
const { headIssues, baseIssues } = data;
if (!headIssues || !baseIssues) {
// eslint-disable-next-line no-restricted-globals
return self.postMessage({});
} }
// eslint-disable-next-line no-restricted-globals // eslint-disable-next-line no-restricted-globals
self.postMessage({ self.postMessage({
newIssues: filterByKey(data.parsedHeadIssues, data.parsedBaseIssues, keyToFilterBy), newIssues: filterByKey(headIssues, baseIssues, keyToFilterBy),
resolvedIssues: filterByKey(data.parsedBaseIssues, data.parsedHeadIssues, keyToFilterBy), resolvedIssues: filterByKey(baseIssues, headIssues, keyToFilterBy),
}); });
// eslint-disable-next-line no-restricted-globals // eslint-disable-next-line no-restricted-globals
self.close(); return self.close();
}); });
---
title: Fix variable mismatch in code quality widget
merge_request: 14829
author:
type: fixed
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