Skip to content

Commit 8989d0e

Browse files
committed
fix types & better variable names
1 parent c2852a3 commit 8989d0e

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

site/frontend/src/pages/status_new/collector.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<script setup lang="ts">
2-
import {computed} from "vue";
3-
import {BenchmarkRequest} from "./data";
2+
import {CollectorConfigAndWork, CollectorConfig} from "./data";
43
54
const props = defineProps<{
65
collector: CollectorConfigAndWork;
76
}>();
87
8+
/* trick typescript into thinking props is used. We _have_ to define it else
9+
* `collector` in the below code is untyped and thus fails to compile */
10+
<any>props;
11+
912
function statusClass(c: CollectorConfig): string {
1013
return c.isActive ? "active" : "inactive";
1114
}

site/frontend/src/pages/status_new/data.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ export function createCollectorJobMap(
191191
collectorConfigs: CollectorConfig[],
192192
inProgress: StatusResponseInProgress[]
193193
): CollectorJobMap {
194-
const ht: CollectorJobMap = {};
194+
const collectorJobMap: CollectorJobMap = {};
195195

196196
for (const collectorConfig of collectorConfigs) {
197-
ht[collectorConfig.name] = {
197+
collectorJobMap[collectorConfig.name] = {
198198
request: null,
199199
jobs: [],
200200
config: collectorConfig,
@@ -216,13 +216,13 @@ export function createCollectorJobMap(
216216
backend: j.backend,
217217
dequeCounter: j.dequeCounter,
218218
};
219-
if (ht[j.status.collectorName].request == null) {
220-
ht[j.status.collectorName].request = simpleReq;
219+
if (collectorJobMap[j.status.collectorName].request == null) {
220+
collectorJobMap[j.status.collectorName].request = simpleReq;
221221
}
222222
/* There will be one in_progress job and a few success/failures*/
223-
ht[j.status.collectorName].jobs.push(simpleJob);
223+
collectorJobMap[j.status.collectorName].jobs.push(simpleJob);
224224
}
225225
}
226226
}
227-
return ht;
227+
return collectorJobMap;
228228
}

site/frontend/src/pages/status_new/page.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,27 @@ import {STATUS_DATA_NEW_URL} from "../../urls";
66
import {withLoading} from "../../utils/loading";
77
import {
88
StatusResponse,
9-
CollectorConfig,
9+
CollectorJobMap,
1010
BenchmarkRequestType,
1111
ReleaseCommit,
1212
createCollectorJobMap,
1313
} from "./data";
14-
import Collector from "./collector";
14+
import Collector from "./collector.vue";
1515
1616
async function loadStatusNew(loading: Ref<boolean>) {
1717
dataNew.value = await withLoading(loading, async () => {
18-
let d = await getJson<StatusResponse>(STATUS_DATA_NEW_URL);
18+
let d: StatusResponse = await getJson<StatusResponse>(STATUS_DATA_NEW_URL);
1919
return {
2020
...d,
21-
ht: createCollectorJobMap(d.collectorConfigs, d.inProgress),
21+
collectorJobMap: createCollectorJobMap(d.collectorConfigs, d.inProgress),
2222
};
2323
});
2424
}
2525
2626
const loading = ref(true);
27-
const dataNew: Ref<StatusResponse | null> = ref(null);
27+
const dataNew: Ref<
28+
(StatusResponse & {collectorJobMap: CollectorJobMap}) | null
29+
> = ref(null);
2830
2931
function pullRequestUrlAsHtml(reqType: BenchmarkRequestType): string {
3032
if (reqType.type === ReleaseCommit) {
@@ -113,7 +115,7 @@ loadStatusNew(loading);
113115
</span>
114116
<h1>Collectors</h1>
115117
<div class="grid">
116-
<div :key="cc[0]" v-for="cc in Object.entries(dataNew.ht)">
118+
<div :key="cc[0]" v-for="cc in Object.entries(dataNew.collectorJobMap)">
117119
<Collector :collector="cc[1]" />
118120
</div>
119121
</div>

0 commit comments

Comments
 (0)