Skip to content

Commit 67ffbd6

Browse files
committed
Fix artifact table display
The table was broken because nightly has recently stopped shipping `libtest.so`, and one piece of the code was accessing `undefined` artifact data. This commit makes component handling more robust.
1 parent 8b21652 commit 67ffbd6

File tree

1 file changed

+44
-51
lines changed

1 file changed

+44
-51
lines changed

site/frontend/src/pages/compare/artifact-size/artifact-size-table.vue

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,37 @@ const props = defineProps<{
1313
b: ArtifactDescription;
1414
}>();
1515
16+
interface ComponentSize {
17+
name: string;
18+
before: number | undefined;
19+
after: number | undefined;
20+
}
21+
22+
const allComponents: ComponentSize[] = [
23+
...new Set([
24+
...Object.keys(props.a.component_sizes),
25+
...Object.keys(props.b.component_sizes),
26+
]),
27+
].map((name) => {
28+
const before = props.a.component_sizes[name];
29+
const after = props.b.component_sizes[name];
30+
return {
31+
name,
32+
before,
33+
after,
34+
};
35+
});
36+
1637
// Sort binaries first, libraries later. Then within each category, sort alphabetically.
17-
const components = Object.keys(props.a.component_sizes).sort((a, b) => {
18-
const aLib = a.startsWith("lib");
19-
const bLib = b.startsWith("lib");
38+
const components = allComponents.sort((a, b) => {
39+
const aLib = isLibrary(a.name);
40+
const bLib = isLibrary(b.name);
2041
if (aLib && !bLib) {
2142
return 1;
2243
} else if (!aLib && bLib) {
2344
return -1;
2445
} else {
25-
return a.localeCompare(b);
46+
return a.name.localeCompare(b.name);
2647
}
2748
});
2849
@@ -54,6 +75,13 @@ function formatChangeTitle(
5475
return (b - a).toLocaleString();
5576
}
5677
78+
function formatTitle(value: number | undefined): string {
79+
if (!isValidValue(value)) {
80+
return "Missing value";
81+
}
82+
return value.toLocaleString();
83+
}
84+
5785
function formatChange(a: number | undefined, b: number | undefined): string {
5886
if (!isValidValue(a) || !isValidValue(b)) {
5987
return "-";
@@ -111,68 +139,33 @@ function generateTitle(component: string): string {
111139
<tbody>
112140
<tr v-for="component in components">
113141
<td class="component">
114-
{{ formatName(component) }}
115-
<Tooltip>{{ generateTitle(component) }}</Tooltip>
142+
{{ formatName(component.name) }}
143+
<Tooltip>{{ generateTitle(component.name) }}</Tooltip>
116144
</td>
117145
<td>
118-
{{ isLibrary(component) ? "Library" : "Binary" }}
146+
{{ isLibrary(component.name) ? "Library" : "Binary" }}
119147
</td>
120148
<td>
121-
<div
122-
class="aligned"
123-
:title="a.component_sizes[component].toLocaleString()"
124-
>
125-
{{ formatValue(a.component_sizes[component]) }}
149+
<div class="aligned" :title="formatTitle(component.before)">
150+
{{ formatValue(component.before) }}
126151
</div>
127152
</td>
128153
<td>
129-
<div
130-
class="aligned"
131-
:title="b.component_sizes[component].toLocaleString()"
132-
>
133-
{{ formatValue(b.component_sizes[component]) }}
154+
<div class="aligned" :title="formatTitle(component.after)">
155+
{{ formatValue(component.after) }}
134156
</div>
135157
</td>
136-
<td
137-
:class="
138-
getClass(
139-
a.component_sizes[component],
140-
b.component_sizes[component]
141-
)
142-
"
143-
>
158+
<td :class="getClass(component.before, component.after)">
144159
<div
145160
class="aligned"
146-
:title="
147-
formatChangeTitle(
148-
a.component_sizes[component],
149-
b.component_sizes[component]
150-
)
151-
"
161+
:title="formatChangeTitle(component.before, component.after)"
152162
>
153-
{{
154-
formatChange(
155-
a.component_sizes[component],
156-
b.component_sizes[component]
157-
)
158-
}}
163+
{{ formatChange(component.before, component.after) }}
159164
</div>
160165
</td>
161-
<td
162-
:class="
163-
getClass(
164-
a.component_sizes[component],
165-
b.component_sizes[component]
166-
)
167-
"
168-
>
166+
<td :class="getClass(component.before, component.after)">
169167
<div class="aligned">
170-
{{
171-
formatPercentChange(
172-
a.component_sizes[component],
173-
b.component_sizes[component]
174-
)
175-
}}
168+
{{ formatPercentChange(component.before, component.after) }}
176169
</div>
177170
</td>
178171
</tr>

0 commit comments

Comments
 (0)