Uses status from DB

This commit is contained in:
Mihovil Ilakovac 2023-06-29 16:07:21 +02:00
parent 3b6b6ddf1a
commit 23d29cb370
4 changed files with 21 additions and 11 deletions

View File

@ -49,6 +49,7 @@ entity Project {=psl
name String
description String
createdAt DateTime @default(now())
status String @default("in-progress")
files File[]
logs Log[]
psl=}

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Project" ADD COLUMN "status" TEXT NOT NULL DEFAULT 'in-progress';

View File

@ -30,14 +30,14 @@ export const ResultPage = () => {
useEffect(() => {
if (
appGenerationResult?.status === "success" ||
appGenerationResult?.status === "failure"
appGenerationResult?.project?.status === "success" ||
appGenerationResult?.project?.status === "failure"
) {
setGenerationDone(true);
setCurrentStatus({
status: appGenerationResult.status === "success" ? "success" : "error",
status: appGenerationResult.project.status === "success" ? "success" : "error",
message:
appGenerationResult.status === "success"
appGenerationResult.project.status === "success"
? "Finished"
: "There was an error",
});

View File

@ -35,7 +35,6 @@ export const startGeneratingNewApp: StartGeneratingNewApp<
const appId = project.id;
appGenerationResults[appId] = {
status: "in-progress",
unconsumedStdout: "",
};
@ -132,17 +131,26 @@ export const startGeneratingNewApp: StartGeneratingNewApp<
console.error(data.toString());
});
waspCliProcess.on("close", (code) => {
waspCliProcess.on("close", async (code) => {
if (code === 0) {
appGenerationResults[appId].status = "success";
await Project.update({
where: { id: appId },
data: { status: "success" },
});
} else {
appGenerationResults[appId].status = "failure";
await Project.update({
where: { id: appId },
data: { status: "failure" },
});
}
});
waspCliProcess.on("error", (err) => {
waspCliProcess.on("error", async (err) => {
console.error("WASP CLI PROCESS ERROR", err);
appGenerationResults[appId].status = "failure";
await Project.update({
where: { id: appId },
data: { status: "failure" },
});
});
return appId;
@ -164,7 +172,6 @@ export const getAppGenerationResult = (async (args, context) => {
},
});
return {
status: appGenerationResults[appId]?.status ?? "success",
project,
};
} catch (e) {