Skip to content

Commit

Permalink
JobsData type bug fix (#925)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewThien authored Dec 18, 2024
1 parent 96b3e44 commit 2747122
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export const columns: ColumnDef<ScanReportTable>[] = [
// Divide jobs into jobs groups
const jobGroups = DivideJobs(jobsData);
// Get the general status of the table for the lastest run
const generalStatus = FindGeneralStatus(jobGroups[0]);
const generalStatus =
jobGroups.length > 0 ? FindGeneralStatus(jobGroups[0]) : "NOT_STARTED";

return (
<div className="flex justify-center">
Expand All @@ -83,7 +84,8 @@ export const columns: ColumnDef<ScanReportTable>[] = [
// Divide jobs into jobs groups
const jobGroups = DivideJobs(jobsData);
// Get the general status of the table for the lastest run
const generalStatus = FindGeneralStatus(jobGroups[0]);
const generalStatus =
jobGroups.length > 0 ? FindGeneralStatus(jobGroups[0]) : "NOT_STARTED";
return (
<EditButton
scanreportId={scan_report}
Expand Down
30 changes: 14 additions & 16 deletions app/next-client-app/components/jobs/JobUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
export const FindGeneralStatus = (jobsData: Job[]) => {
let generalStatus = "NOT_STARTED";
if (jobsData.length > 0) {
if (
jobsData?.some((job) => job.status && job.status.value === "IN_PROGRESS")
) {
generalStatus = "IN_PROGRESS";
} else if (
jobsData?.some((job) => job.status && job.status.value === "FAILED")
) {
generalStatus = "FAILED";
} else if (
jobsData?.every((job) => job.status && job.status.value === "COMPLETE")
) {
generalStatus = "COMPLETE";
}
if (
jobsData.some((job) => job.status && job.status.value === "IN_PROGRESS")
) {
return "IN_PROGRESS";
}

if (jobsData.some((job) => job.status && job.status.value === "FAILED")) {
return "FAILED";
}
return generalStatus;

if (jobsData.every((job) => job.status && job.status.value === "COMPLETE")) {
return "COMPLETE";
}

return "NOT_STARTED";
};

export const DivideJobs = (jobsData: Job[]) => {
Expand Down

0 comments on commit 2747122

Please sign in to comment.