Skip to content

Commit a76ae7c

Browse files
committed
Simplify loading of backend data in new status page
1 parent a0b15c9 commit a76ae7c

File tree

9 files changed

+165
-260
lines changed

9 files changed

+165
-260
lines changed

database/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,10 +957,10 @@ impl BenchmarkRequest {
957957
}
958958
}
959959

960-
pub fn pr(&self) -> Option<&u32> {
960+
pub fn pr(&self) -> Option<u32> {
961961
match &self.commit_type {
962962
BenchmarkRequestType::Try { pr, .. } | BenchmarkRequestType::Master { pr, .. } => {
963-
Some(pr)
963+
Some(*pr)
964964
}
965965
BenchmarkRequestType::Release { .. } => None,
966966
}

database/src/pool.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ mod tests {
575575
.await
576576
.unwrap();
577577

578-
complete_request(&*db, "sha-parent-1", collector_name, benchmark_set, target).await;
579-
complete_request(&*db, "sha1", collector_name, benchmark_set, target).await;
578+
complete_request(db, "sha-parent-1", collector_name, benchmark_set, target).await;
579+
complete_request(db, "sha1", collector_name, benchmark_set, target).await;
580580

581581
// This should be fine, req_a was completed
582582
db.insert_benchmark_request(&req_b).await.unwrap();
@@ -647,7 +647,7 @@ mod tests {
647647
db.insert_benchmark_request(req).await.unwrap();
648648
}
649649

650-
complete_request(&*db, "1.79.0", collector_name, benchmark_set, target).await;
650+
complete_request(db, "1.79.0", collector_name, benchmark_set, target).await;
651651

652652
db.update_benchmark_request_status("sha-2", BenchmarkRequestStatus::InProgress)
653653
.await
@@ -697,7 +697,7 @@ mod tests {
697697

698698
assert_eq!(req_db.tag(), Some("sha1"));
699699
assert_eq!(req_db.parent_sha(), Some("sha-parent-1"));
700-
assert_eq!(req_db.pr(), Some(&42));
700+
assert_eq!(req_db.pr(), Some(42));
701701

702702
Ok(ctx)
703703
})

database/src/pool/postgres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ where
15651565
&[
15661566
&benchmark_request.tag(),
15671567
&benchmark_request.parent_sha(),
1568-
&benchmark_request.pr().map(|it| *it as i32),
1568+
&benchmark_request.pr().map(|it| it as i32),
15691569
&benchmark_request.commit_type,
15701570
&benchmark_request.status.as_str(),
15711571
&benchmark_request.created_at,

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
<script setup lang="ts">
2-
import {BenchmarkJob, CollectorInfo, CollectorConfig} from "./data";
2+
import {CollectorConfig} from "./data";
33
44
const props = defineProps<{
5-
collector: CollectorInfo;
6-
jobMap: Dict<BenchmarkJob>;
5+
collector: CollectorConfig;
76
}>();
87
98
function statusClass(c: CollectorConfig): string {
109
return c.isActive ? "active" : "inactive";
1110
}
12-
13-
function getStartedAt(j: BenchmarkJob): string {
14-
return "startedAt" in j.status ? j.status.startedAt : "";
15-
}
1611
</script>
1712

1813
<template>
@@ -21,17 +16,17 @@ function getStartedAt(j: BenchmarkJob): string {
2116
<div class="collector-name">
2217
<span>
2318
<strong class="collector-sm-padding-right">{{
24-
props.collector.config.name
19+
props.collector.name
2520
}}</strong>
2621
<span
2722
class="collector-sm-padding-left-right collector-left-divider"
28-
>{{ collector.config.target }}</span
23+
>{{ collector.target }}</span
2924
>
3025
<span
3126
class="collector-sm-padding-left-right status"
32-
:class="statusClass(collector.config)"
27+
:class="statusClass(collector)"
3328
>
34-
{{ collector.config.isActive ? "Active" : "Inactive" }}
29+
{{ collector.isActive ? "Active" : "Inactive" }}
3530
</span>
3631
</span>
3732
</div>
@@ -42,21 +37,21 @@ function getStartedAt(j: BenchmarkJob): string {
4237
<span class="collector-meta-name">
4338
<strong>Benchmark Set:</strong>
4439
</span>
45-
<span> #{{ collector.config.benchmarkSet }}</span>
40+
<span> #{{ collector.benchmarkSet }}</span>
4641
</div>
4742

4843
<div class="collector-meta">
4944
<span class="collector-meta-name">
5045
<strong>Last Heartbeat:</strong>
5146
</span>
52-
<span>{{ collector.config.lastHeartbeatAt }}</span>
47+
<span>{{ collector.lastHeartbeatAt }}</span>
5348
</div>
5449

5550
<div class="collector-meta">
5651
<span class="collector-meta-name">
5752
<strong>Date Added:</strong>
5853
</span>
59-
<span>{{ collector.config.dateAdded }}</span>
54+
<span>{{ collector.dateAdded }}</span>
6055
</div>
6156
</div>
6257

@@ -76,28 +71,28 @@ function getStartedAt(j: BenchmarkJob): string {
7671
</tr>
7772
</thead>
7873
<tbody>
79-
<tr v-for="id in collector.jobIds">
74+
<tr v-for="job in collector.jobs">
8075
<td class="table-cell-padding">
81-
{{ jobMap[id].requestTag }}
76+
{{ job.requestTag }}
8277
</td>
8378
<td class="table-cell-padding">
84-
{{ jobMap[id].status.state }}
79+
{{ job.status }}
8580
</td>
8681
<td class="table-cell-padding">
87-
{{ getStartedAt(jobMap[id]) }}
82+
{{ job.startedAt }}
8883
</td>
89-
<td class="table-cell-padding">{{ jobMap[id].backend }}</td>
90-
<td class="table-cell-padding">{{ jobMap[id].profile }}</td>
84+
<td class="table-cell-padding">{{ job.backend }}</td>
85+
<td class="table-cell-padding">{{ job.profile }}</td>
9186
<td class="table-cell-padding">
92-
{{ jobMap[id].dequeCounter }}
87+
{{ job.dequeCounter }}
9388
</td>
9489
</tr>
9590
</tbody>
9691
</table>
9792
</div>
9893

99-
<div class="collector-no-work" v-if="collector.jobIds.length === 0">
100-
<h3>no active benchmarks 🦦</h3>
94+
<div class="collector-no-work" v-if="collector.jobs.length === 0">
95+
<h3>no active benchmarks</h3>
10196
</div>
10297
</div>
10398
</template>
Lines changed: 16 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,28 @@
1-
export const BenchmarkRequestCompleteStr = "completed";
2-
export const BenchmarkRequestInProgressStr = "in_progress";
3-
export const BenchmarkRequestArtifactsReadyStr = "artifacts_ready";
1+
export type BenchmarkRequestType = "Release" | "Master" | "Try";
2+
export type BenchmarkRequestStatus = "Queued" | "InProgress" | "Completed";
43

5-
type BenchmarkRequestStatusComplete = {
6-
state: typeof BenchmarkRequestCompleteStr;
7-
completedAt: string;
8-
duration_s: number;
9-
};
10-
11-
type BenchmarkRequestStatusInProgress = {
12-
state: typeof BenchmarkRequestInProgressStr;
13-
};
14-
15-
type BenchmarkRequestStatusArtifactsReady = {
16-
state: typeof BenchmarkRequestArtifactsReadyStr;
17-
};
18-
19-
export type BenchmarkRequestStatus =
20-
| BenchmarkRequestStatusComplete
21-
| BenchmarkRequestStatusInProgress
22-
| BenchmarkRequestStatusArtifactsReady;
23-
24-
export const TryCommit = "Try";
25-
export const MasterCommit = "Master";
26-
export const ReleaseCommit = "Release";
27-
28-
type BenchmarkRequestTypeTry = {
29-
type: typeof TryCommit;
30-
tag: string | null;
31-
parent_sha: string | null;
32-
pr: number;
33-
};
34-
35-
type BenchmarkRequestTypeMaster = {
36-
type: typeof MasterCommit;
4+
export type BenchmarkRequest = {
375
tag: string;
38-
parent_sha: string;
39-
pr: number;
40-
};
41-
42-
type BenchmarkRequestTypeRelease = {
43-
type: typeof ReleaseCommit;
44-
tag: string;
45-
};
46-
47-
export type BenchmarkRequestTypeStr =
48-
| typeof ReleaseCommit
49-
| typeof MasterCommit
50-
| typeof TryCommit;
51-
52-
export type BenchmarkRequestType =
53-
| BenchmarkRequestTypeTry
54-
| BenchmarkRequestTypeMaster
55-
| BenchmarkRequestTypeRelease;
56-
57-
export type BenchmarkRequestComplete = {
58-
status: BenchmarkRequestStatusComplete;
59-
requestType: BenchmarkRequestType;
60-
commitDate: string | null;
61-
createdAt: string | null;
62-
backends: string[];
63-
profiles: string;
64-
errors: string[];
65-
};
66-
67-
export type BenchmarkRequestInProgress = {
68-
status: BenchmarkRequestStatusInProgress;
6+
pr: number | null;
7+
status: BenchmarkRequestStatus;
698
requestType: BenchmarkRequestType;
70-
commitDate: string | null;
71-
createdAt: string | null;
72-
backends: string[];
73-
profiles: string;
74-
errors: string[];
75-
};
76-
77-
export type BenchmarkRequestArtifactsReady = {
78-
status: BenchmarkRequestStatusArtifactsReady;
79-
requestType: BenchmarkRequestType;
80-
commitDate: string | null;
81-
createdAt: string | null;
82-
backends: string[];
83-
profiles: string;
84-
errors: string[];
85-
};
86-
87-
export type BenchmarkRequest =
88-
| BenchmarkRequestComplete
89-
| BenchmarkRequestInProgress
90-
| BenchmarkRequestArtifactsReady;
91-
92-
export const BenchmarkJobQueued = "queued";
93-
export const BenchmarkJobInProgress = "in_progres";
94-
export const BenchmarkJobFailed = "failed";
95-
export const BenchmarkJobSuccess = "success";
96-
97-
export type BenchmarkJobStatusQueued = {
98-
state: typeof BenchmarkJobQueued;
99-
};
100-
101-
export type BenchmarkJobStatusInProgress = {
102-
state: typeof BenchmarkJobInProgress;
103-
startedAt: string;
104-
collectorName: string;
105-
};
106-
107-
export type BenchmarkJobStatusFailed = {
108-
state: typeof BenchmarkJobFailed;
109-
startedAt: string;
110-
completedAt: string;
111-
collectorName: string;
112-
};
113-
114-
export type BenchmarkJobStatusSuccess = {
115-
state: typeof BenchmarkJobSuccess;
116-
startedAt: string;
117-
completedAt: string;
118-
collectorName: string;
9+
createdAt: string;
10+
completedAt: string | null;
11+
durationS: number | null;
12+
errors: Dict<string>;
11913
};
12014

121-
export type BenchmarkJobStatusStr =
122-
| typeof BenchmarkJobQueued
123-
| typeof BenchmarkJobInProgress
124-
| typeof BenchmarkJobFailed
125-
| typeof BenchmarkJobSuccess;
126-
127-
export type BenchmarkJobStatus =
128-
| BenchmarkJobStatusSuccess
129-
| BenchmarkJobStatusFailed
130-
| BenchmarkJobStatusInProgress
131-
| BenchmarkJobStatusQueued;
15+
export type BenchmarkJobStatus = "Queued" | "InProgress" | "Success" | "Failed";
13216

13317
export type BenchmarkJob = {
18+
requestTag: string;
13419
target: string;
13520
backend: string;
13621
profile: string;
137-
requestTag: string;
13822
benchmarkSet: number;
13923
createdAt: string;
24+
startedAt: string | null;
25+
completedAt: string | null;
14026
status: BenchmarkJobStatus;
14127
dequeCounter: number;
14228
};
@@ -148,17 +34,10 @@ export type CollectorConfig = {
14834
isActive: boolean;
14935
lastHeartbeatAt: string;
15036
dateAdded: string;
151-
};
152-
153-
export type CollectorInfo = {
154-
config: CollectorConfig;
155-
jobIds: number[];
37+
jobs: BenchmarkJob[];
15638
};
15739

15840
export type StatusResponse = {
159-
queueRequestTags: string[];
160-
requestsMap: Dict<BenchmarkRequest>;
161-
jobMap: Dict<BenchmarkJob>;
162-
collectorWorkMap: Dict<CollectorInfo>;
163-
tagToJobs: Dict<number[]>;
41+
requests: BenchmarkRequest[];
42+
collectors: CollectorConfig[];
16443
};

0 commit comments

Comments
 (0)