Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gui] Improve component statistics page load #3018

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,13 @@ export default {
},
methods: {
getComponentStatistics(component, runIds, reportFilter, cmpData) {
const queries = [
{ field: null, values: null },
{ field: "severity", values: [ Severity.CRITICAL ] },
{ field: "severity", values: [ Severity.HIGH ] },
{ field: "severity", values: [ Severity.MEDIUM ] },
{ field: "severity", values: [ Severity.LOW ] },
{ field: "severity", values: [ Severity.STYLE ] },
{ field: "severity", values: [ Severity.UNSPECIFIED ] },
].map(q => {
const filter = new ReportFilter(reportFilter);
const filter = new ReportFilter(reportFilter);
filter["severity"] = null;
filter["componentNames"] = [ component.name ];

if (q.field) {
filter[q.field] = q.values;
}

filter["componentNames"] = [ component.name ];

return new Promise(resolve => {
ccService.getClient().getRunResultCount(runIds, filter, cmpData,
handleThriftError(resultCount => resolve(resultCount)));
});
});

return Promise.all(queries);
return new Promise(resolve =>
ccService.getClient().getSeverityCounts(runIds, filter, cmpData,
handleThriftError(res => resolve(res))));
},

initStatistics(components) {
Expand All @@ -180,16 +163,21 @@ export default {
const res = await this.getComponentStatistics(component, runIds,
reportFilter, cmpData);

const reports = Object.keys(res).reduce((acc, curr) => {
acc += res[curr].toNumber();
return acc;
}, 0);

return {
component : component.name,
value : component.value || component.description,
reports : initDiffField(res[0]),
critical : initDiffField(res[1]),
high : initDiffField(res[2]),
medium : initDiffField(res[3]),
low : initDiffField(res[4]),
style : initDiffField(res[5]),
unspecified : initDiffField(res[6])
reports : initDiffField(reports),
critical : initDiffField(res[Severity.CRITICAL]),
high : initDiffField(res[Severity.HIGH]),
medium : initDiffField(res[Severity.MEDIUM]),
low : initDiffField(res[Severity.LOW]),
style : initDiffField(res[Severity.STYLE]),
unspecified : initDiffField(res[Severity.UNSPECIFIED])
};
},
}
Expand Down
58 changes: 28 additions & 30 deletions web/server/vue-cli/src/components/Statistics/StatisticsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,36 +119,34 @@ function getComponents() {
async function getComponentStatistics(component, runIds, reportFilter,
cmpData
) {
const queries = [
{ field: null, values: null },
{ field: "reviewStatus", values: [ ReviewStatus.UNREVIEWED ] },
{ field: "reviewStatus", values: [ ReviewStatus.CONFIRMED ] },
{ field: "reviewStatus", values: [ ReviewStatus.FALSE_POSITIVE ] },
{ field: "reviewStatus", values: [ ReviewStatus.INTENTIONAL ] }
].map(q => {
const filter = new ReportFilter(reportFilter);

if (q.field) {
filter[q.field] = q.values;
}

filter["componentNames"] = [ component.name ];

return new Promise(resolve => {
ccService.getClient().getRunResultCount(runIds, filter, cmpData,
handleThriftError(resultCount => resolve(resultCount)));
});
});

return (await Promise.all(queries)).map(res => ({
reports : res[0],
unreviewed : res[1],
confirmed : res[2],
outstanding : (res[1]?.toNumber() || 0) + (res[2]?.toNumber() || 0),
falsePositive : res[3],
intentional : res[4],
suppressed : (res[3]?.toNumber() || 0) + (res[4]?.toNumber() || 0)
}));
const filter = new ReportFilter(reportFilter);
filter["reviewStatus"] = null;
filter["componentNames"] = [ component.name ];

const res = await new Promise(resolve =>
ccService.getClient().getReviewStatusCounts(runIds, filter, cmpData,
handleThriftError(res => resolve(res))));

const outstanding = (res[ReviewStatus.UNREVIEWED]?.toNumber() || 0) +
(res[ReviewStatus.CONFIRMED]?.toNumber() || 0);

const suppressed = (res[ReviewStatus.FALSE_POSITIVE]?.toNumber() || 0) +
(res[ReviewStatus.INTENTIONAL]?.toNumber() || 0);

const reports = Object.keys(res).reduce((acc, curr) => {
acc += res[curr].toNumber();
return acc;
}, 0);

return {
reports : reports,
unreviewed : res[ReviewStatus.UNREVIEWED],
confirmed : res[ReviewStatus.CONFIRMED],
outstanding : outstanding,
falsePositive : res[ReviewStatus.FALSE_POSITIVE],
intentional : res[ReviewStatus.INTENTIONAL],
suppressed : suppressed
};
}

export {
Expand Down