-
Notifications
You must be signed in to change notification settings - Fork 123
Open
Description
Instead of polling all the images, and checking all of them if they are Generated or not, once we generate images, pass on the request_ids to the frontend, and use these request_ids to poll the backend,
Here's the backend polling endpoint :
router.get("/poll/images/:requestId", async (req, res) => {
const requestId = req.params.requestId;
const request = await prisma.requests.findUnique({
where: {
requestId: requestId
}
})
if (request?.status === "completed") {
const image = request?.imageGenerated;
res.status(200).json({ message: "success", imageGenerated: image });
} else {
res.status(400).json({ message: "pending" });
}
})
Please note for adding this change, it would require structural DB change, where we will have another Table - Requests
model Requests {
id String @id @default(auto()) @map("_id") @db.ObjectId
status String @default("pending") // pending, completed, failed
requestId String @unique
stripeId String
imageGenerated String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels