Skip to content

Commit

Permalink
fix(analysis): move pod check hack to button component build_image
Browse files Browse the repository at this point in the history
  • Loading branch information
brucetony committed Sep 25, 2024
1 parent eccabba commit 67c3c51
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 43 deletions.
33 changes: 0 additions & 33 deletions components/analysis/AnalysesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
AnalysisBuildStatus,
type AnalysisNode,
AnalysisNodeRunStatus,
AnalysisRunStatus,
ApprovalStatus,
type Project,
} from "~/services/Api";
Expand Down Expand Up @@ -68,45 +67,13 @@ 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;
}
async function onTableRefresh() {
await refresh();
parseData();
checkRunStatuses(); // TODO: remove
}
// Table filters
Expand Down
36 changes: 26 additions & 10 deletions components/analysis/AnalysisControlButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {
AnalysisBuildStatus,
AnalysisNodeRunStatus,
AnalysisRunStatus,
type BodyCreateAnalysisPoPost,
} from "~/services/Api";
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 67c3c51

Please sign in to comment.