From 67c3c51904cb8ea687a16b780c5ca18b21a86aa1 Mon Sep 17 00:00:00 2001 From: Bruce Schultz Date: Wed, 25 Sep 2024 09:00:50 +0200 Subject: [PATCH] fix(analysis): move pod check hack to button component build_image --- components/analysis/AnalysesTable.vue | 33 ----------------- .../analysis/AnalysisControlButtons.vue | 36 +++++++++++++------ 2 files changed, 26 insertions(+), 43 deletions(-) diff --git a/components/analysis/AnalysesTable.vue b/components/analysis/AnalysesTable.vue index c20fb4f..fdd68da 100644 --- a/components/analysis/AnalysesTable.vue +++ b/components/analysis/AnalysesTable.vue @@ -15,7 +15,6 @@ import { AnalysisBuildStatus, type AnalysisNode, AnalysisNodeRunStatus, - AnalysisRunStatus, ApprovalStatus, type Project, } from "~/services/Api"; @@ -68,37 +67,6 @@ function parseData() { } parseData(); -// TODO: remove -function checkRunStatuses() { - const analysesData = response.value!.data; - for (const analysisNode of analysesData) { - if ( - analysisNode.analysis?.build_status === AnalysisBuildStatus.Finished && - !analysisNode.run_status - ) { - const analysisId = analysisNode.analysis_id; - - useLazyFetch(`/po/${analysisId}/pods`, { - $fetch: useNuxtApp().$hubApi, - }) - .then(({ data: prevLogResp, status: podCheckStatus }) => { - watch(prevLogResp, () => { - if ( - podCheckStatus.value === "success" && - prevLogResp.value.pods.length > 0 - ) { - updateRunStatus(analysisNode.id, AnalysisRunStatus.Running); - } - }); - }) - .catch((error) => console.error(error)); - } - } -} -if (analyses.value.length < 10) { - checkRunStatuses(); -} - function onToggleRowExpansion(rowIds) { expandedRows.value = rowIds; } @@ -106,7 +74,6 @@ function onToggleRowExpansion(rowIds) { async function onTableRefresh() { await refresh(); parseData(); - checkRunStatuses(); // TODO: remove } // Table filters diff --git a/components/analysis/AnalysisControlButtons.vue b/components/analysis/AnalysisControlButtons.vue index e6cb4e4..6d9bbcb 100644 --- a/components/analysis/AnalysisControlButtons.vue +++ b/components/analysis/AnalysisControlButtons.vue @@ -2,6 +2,7 @@ import { AnalysisBuildStatus, AnalysisNodeRunStatus, + AnalysisRunStatus, type BodyCreateAnalysisPoPost, } from "~/services/Api"; @@ -41,18 +42,33 @@ const deleteButtonActiveStates = [ AnalysisNodeRunStatus.Started, ]; -const buttonStatuses = ref(setButtonStatuses(props.analysisRunStatus)); +const buttonStatuses = ref(setButtonStatuses(props.analysisRunStatus, false)); + +// TODO: remove when manual pod status checks are implemented by the PodOrc +const runStatus = ref(props.analysisRunStatus); +if ( + props.analysisBuildStatus === AnalysisBuildStatus.Finished && + !runStatus.value +) { + useNuxtApp() + .$hubApi(`/po/${props.analysisId}/pods`, { + lazy: true, + method: "GET", + }) + .then((prevLogResp) => { + if (prevLogResp.pods.length > 0) { + runStatus.value = AnalysisRunStatus.Running; + buttonStatuses.value = setButtonStatuses(AnalysisRunStatus.Running); + } + }) + .catch((error) => console.warn(error)); +} -// TODO: possibly remove when manual pod status checks are removed -watch( - () => props.analysisRunStatus, - () => { - buttonStatuses.value = setButtonStatuses(props.analysisRunStatus); - }, -); +function setButtonStatuses(podStatus: string, updateTable: boolean = true) { + if (updateTable) { + emit("newRunStatus", props.analysisNodeId, podStatus); + } -function setButtonStatuses(podStatus: string) { - emit("newRunStatus", props.analysisNodeId, podStatus); return { playActive: playButtonActiveStates.includes(podStatus), rerunActive: rerunButtonActiveStates.includes(podStatus),