Skip to content

Commit

Permalink
feat(apps/spu-ui): refine its result schema and simplify history item…
Browse files Browse the repository at this point in the history
… status handling
  • Loading branch information
brnovasco committed Dec 18, 2024
1 parent ad9010a commit 98ad824
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
5 changes: 1 addition & 4 deletions apps/spu-ui/src/app/_components/history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,10 @@ function UnknownItem({
function HistoryItem({ props }: { props: HistoryItemProps }) {
const { data: planParams } = schema.safeParse(props.kwargs);
const status = function () {
if (!props.result) {
return "unknown";
}
if (props.result.traceback) {
return props.result.exitStatus ?? "failed";
}
return props.result.exitStatus ?? "finished";
return props.result.exitStatus ?? "unknown";
};
if (!planParams) {
return <UnknownItem props={props} status={status()} />;
Expand Down
21 changes: 9 additions & 12 deletions packages/api/src/schemas/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ const getResponseSchema = z.object({
user: z.string(),
userGroup: z.string(),
itemUid: z.string().uuid(),
result: z
.object({
exitStatus: z.string().optional(),
runUids: z.array(z.string()),
scanIds: z.array(z.string()),
timeStart: z.number(),
timeStop: z.number(),
msg: z.string().optional(),
traceback: z.string().optional(),
})
.optional()
.nullable(),
result: z.object({
exitStatus: z.string().optional(),
runUids: z.array(z.string()),
scanIds: z.array(z.string()),
timeStart: z.number(),
timeStop: z.number(),
msg: z.string().optional(),
traceback: z.string().optional(),
}),
}),
),
planHistoryUid: z.string().uuid(),
Expand Down

0 comments on commit 98ad824

Please sign in to comment.