diff --git a/site/frontend/src/pages/status/page.vue b/site/frontend/src/pages/status/page.vue index 4633b529c..57261b12d 100644 --- a/site/frontend/src/pages/status/page.vue +++ b/site/frontend/src/pages/status/page.vue @@ -2,6 +2,7 @@ import {getJson} from "../../utils/requests"; import {STATUS_DATA_URL} from "../../urls"; import {withLoading} from "../../utils/loading"; +import {formatDuration} from "../../utils/formatting"; import {computed, ref, Ref} from "vue"; import { Artifact, @@ -26,23 +27,6 @@ async function loadStatus(loading: Ref) { ); } -function formatDuration(seconds: number): string { - let secs = seconds % 60; - let mins = Math.trunc(seconds / 60); - let hours = Math.trunc(mins / 60); - mins -= hours * 60; - - let s = ""; - if (hours > 0) { - s = `${hours}h ${mins < 10 ? "0" + mins : mins}m ${ - secs < 10 ? "0" + secs : secs - }s`; - } else { - s = `${mins < 10 ? " " + mins : mins}m ${secs < 10 ? "0" + secs : secs}s`; - } - return s; -} - function getArtifactPr(reason: MissingReason): number { if (reason.hasOwnProperty("InProgress")) { return getArtifactPr(reason["InProgress"]); diff --git a/site/frontend/src/pages/status_new/collector.vue b/site/frontend/src/pages/status_new/collector.vue new file mode 100644 index 000000000..5f606f93c --- /dev/null +++ b/site/frontend/src/pages/status_new/collector.vue @@ -0,0 +1,228 @@ + + + + + diff --git a/site/frontend/src/pages/status_new/data.ts b/site/frontend/src/pages/status_new/data.ts index 6347e72c6..c578fc91f 100644 --- a/site/frontend/src/pages/status_new/data.ts +++ b/site/frontend/src/pages/status_new/data.ts @@ -1,15 +1,19 @@ +export const BenchmarkRequestCompleteStr = "completed"; +export const BenchmarkRequestInProgressStr = "in_progress"; +export const BenchmarkRequestArtifactsReadyStr = "artifacts_ready"; + type BenchmarkRequestStatusComplete = { - state: "completed"; + state: typeof BenchmarkRequestCompleteStr; completedAt: string; duration: number; // time in milliseconds }; type BenchmarkRequestStatusInProgress = { - state: "in_progress"; + state: typeof BenchmarkRequestInProgressStr; }; type BenchmarkRequestStatusArtifactsReady = { - state: "artifacts_ready"; + state: typeof BenchmarkRequestArtifactsReadyStr; }; export type BenchmarkRequestStatus = @@ -17,26 +21,35 @@ export type BenchmarkRequestStatus = | BenchmarkRequestStatusInProgress | BenchmarkRequestStatusArtifactsReady; +export const TryCommit = "Try"; +export const MasterCommit = "Master"; +export const ReleaseCommit = "Release"; + type BenchmarkRequestTypeTry = { - type: "Try"; + type: typeof TryCommit; tag: string | null; parent_sha: string | null; pr: number; }; type BenchmarkRequestTypeMaster = { - type: "Master"; + type: typeof MasterCommit; tag: string; parent_sha: string; pr: number; }; type BenchmarkRequestTypeRelease = { - type: "Try"; + type: typeof ReleaseCommit; tag: string; }; -type BenchmarkRequestType = +export type BenchmarkRequestTypeStr = + | typeof ReleaseCommit + | typeof MasterCommit + | typeof TryCommit; + +export type BenchmarkRequestType = | BenchmarkRequestTypeTry | BenchmarkRequestTypeMaster | BenchmarkRequestTypeRelease; @@ -76,30 +89,41 @@ export type BenchmarkRequest = | BenchmarkRequestInProgress | BenchmarkRequestArtifactsReady; +export const BenchmarkJobQueued = "queued"; +export const BenchmarkJobInProgress = "in_progres"; +export const BenchmarkJobFailed = "failed"; +export const BenchmarkJobSuccess = "success"; + export type BenchmarkJobStatusQueued = { - state: "queued"; + state: typeof BenchmarkJobQueued; }; export type BenchmarkJobStatusInProgress = { - state: "in_progress"; + state: typeof BenchmarkJobInProgress; startedAt: string; collectorName: string; }; export type BenchmarkJobStatusFailed = { - state: "failed"; + state: typeof BenchmarkJobFailed; startedAt: string; completedAt: string; collectorName: string; }; export type BenchmarkJobStatusSuccess = { - state: "success"; + state: typeof BenchmarkJobSuccess; startedAt: string; completedAt: string; collectorName: string; }; +export type BenchmarkJobStatusStr = + | typeof BenchmarkJobQueued + | typeof BenchmarkJobInProgress + | typeof BenchmarkJobFailed + | typeof BenchmarkJobSuccess; + export type BenchmarkJobStatus = | BenchmarkJobStatusSuccess | BenchmarkJobStatusFailed @@ -137,3 +161,76 @@ export type StatusResponse = { collectorConfigs: CollectorConfig[]; queue: BenchmarkRequest[]; }; + +type SimpleJob = { + state: BenchmarkJobStatusStr; + startedAt: string; + backend: string; + profile: string; + dequeCounter: number; +}; + +type SimpleRequest = { + type: BenchmarkRequestTypeStr; + tag: string; + createdAt: string; +}; + +export type CollectorConfigAndWork = { + jobs: SimpleJob[]; + config: CollectorConfig; + request: SimpleRequest | null; +}; + +export type CollectorJobMap = { + [key: string]: CollectorConfigAndWork; +}; + +/* @TODO; Do this in Rust in the api */ +export function createCollectorJobMap( + collectorConfigs: CollectorConfig[], + inProgress: StatusResponseInProgress[] +): CollectorJobMap { + const collectorJobMap: CollectorJobMap = {}; + + for (const collectorConfig of collectorConfigs) { + collectorJobMap[collectorConfig.name] = { + request: null, + jobs: [], + config: collectorConfig, + }; + } + + for (const {request, jobs} of inProgress) { + const simpleReq: SimpleRequest = { + type: request.requestType.type, + tag: request.requestType.tag, + createdAt: request.createdAt, + }; + for (const j of jobs) { + if (j.status.state !== BenchmarkJobQueued) { + const simpleJob: SimpleJob = { + state: j.status.state, + startedAt: j.status.startedAt, + profile: j.profile, + backend: j.backend, + dequeCounter: j.dequeCounter, + }; + if (collectorJobMap[j.status.collectorName].request == null) { + collectorJobMap[j.status.collectorName].request = simpleReq; + } + /* There will be one in_progress job and a few success/failures*/ + collectorJobMap[j.status.collectorName].jobs.push(simpleJob); + } + } + } + return collectorJobMap; +} + +/* @TODO; Do this in Rust in the api */ +export function createTimeline( + completed: BenchmarkRequestComplete[], + queue: BenchmarkRequest[] +) { + return queue.concat(completed); +} diff --git a/site/frontend/src/pages/status_new/page.vue b/site/frontend/src/pages/status_new/page.vue index 6c3a46aab..a0a33c3ed 100644 --- a/site/frontend/src/pages/status_new/page.vue +++ b/site/frontend/src/pages/status_new/page.vue @@ -1,21 +1,64 @@ -