Skip to content

Commit 9a84c57

Browse files
authored
Merge pull request #1525 from rust-lang/compare-no-relevant-results
Display "No relevant results" on compare page where there are filtered non-relevant results
2 parents 9ba8b8d + 370d497 commit 9a84c57

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

site/static/compare.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
314314
</div>
315315
<test-cases-table
316316
title="Primary"
317-
:cases="testCases.filter(c => c.category === 'primary')"
317+
:cases="primaryCases"
318+
:has-non-relevant="testCasesWithNonRelevant.filter(c => c.category === 'primary').length > 0"
318319
:show-raw-data="filter.showRawData"
319320
:commit-a="data.a"
320321
:commit-b="data.b"
@@ -328,7 +329,8 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
328329
<hr />
329330
<test-cases-table
330331
title="Secondary"
331-
:cases="testCases.filter(c => c.category === 'secondary')"
332+
:cases="secondaryCases"
333+
:has-non-relevant="testCasesWithNonRelevant.filter(c => c.category === 'secondary').length > 0"
332334
:show-raw-data="filter.showRawData"
333335
:commit-a="data.a"
334336
:commit-b="data.b"

site/static/compare/script.js

+19-6
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const app = Vue.createApp({
152152
compareLink() {
153153
return `https://github.com/rust-lang/rust/compare/${this.data.a.commit}...${this.data.b.commit}`;
154154
},
155-
testCases() {
155+
testCasesWithNonRelevant() {
156156
let data = this.data;
157157
const filter = this.filter;
158158
const benchmarkMap = this.benchmarkMap;
@@ -197,13 +197,10 @@ const app = Vue.createApp({
197197
let nameFilter = filter.name && filter.name.trim();
198198
nameFilter = !nameFilter || name.includes(nameFilter);
199199

200-
const relevanceFilter = filter.nonRelevant ? true : testCase.isRelevant;
201-
202200
return (
203201
profileFilter(testCase.profile) &&
204202
scenarioFilter(testCase.scenario) &&
205203
categoryFilter(testCase.category) &&
206-
relevanceFilter &&
207204
nameFilter
208205
);
209206
}
@@ -237,6 +234,15 @@ const app = Vue.createApp({
237234

238235
return testCases;
239236
},
237+
testCases() {
238+
return this.filterNonRelevant(this.testCasesWithNonRelevant);
239+
},
240+
primaryCases() {
241+
return this.testCases.filter(c => c.category === "primary");
242+
},
243+
secondaryCases() {
244+
return this.testCases.filter(c => c.category === "secondary");
245+
},
240246
bootstrapTotals() {
241247
const a = this.data.a.bootstrap_total / 1e9;
242248
const b = this.data.b.bootstrap_total / 1e9;
@@ -377,13 +383,20 @@ const app = Vue.createApp({
377383
},
378384
exportToMarkdown() {
379385
exportToMarkdown(this.testCases);
386+
},
387+
filterNonRelevant(cases) {
388+
if (this.filter.nonRelevant) {
389+
return cases;
390+
}
391+
return cases.filter(c => c.isRelevant);
380392
}
381393
},
382394
});
383395

384396
app.component('test-cases-table', {
385397
props: {
386398
cases: Array,
399+
hasNonRelevant: Boolean,
387400
showRawData: Boolean,
388401
commitA: Object,
389402
commitB: Object,
@@ -433,7 +446,7 @@ app.component('test-cases-table', {
433446
</span>
434447
</div>
435448
<div v-if="cases.length === 0" style="text-align: center;">
436-
No results
449+
{{ hasNonRelevant ? "No relevant results" : "No results" }}
437450
</div>
438451
<table v-else class="benches compare">
439452
<thead>
@@ -555,7 +568,7 @@ const SummaryCount = {
555568
`
556569
};
557570

558-
app.component('summary-table', {
571+
app.component("summary-table", {
559572
props: {
560573
summary: Object,
561574
withLegend: {

0 commit comments

Comments
 (0)