From 590e7e9d9f0d641b4cb1c7ffb7c97f8d84499332 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Thu, 10 Oct 2024 02:23:33 +0530 Subject: [PATCH] feat: successful run + interpretation of robots --- server/src/routes/storage.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/server/src/routes/storage.ts b/server/src/routes/storage.ts index 766daae8..eb5185f1 100644 --- a/server/src/routes/storage.ts +++ b/server/src/routes/storage.ts @@ -207,37 +207,39 @@ router.post('/runs/run/:id', requireSignIn, async (req, res) => { // const parsedRun = JSON.parse(run); console.log(`Params for POST /runs/run/:id`, req.params.id) - const run = await Run.findOne({ where: { runId: req.params.id }, raw: true }); + const run = await Run.findOne({ where: { runId: req.params.id } }); if (!run) { return res.status(404).send(false); } console.log(`found run: ${run}`) - const recording = await Robot.findOne({ where: { 'recording_meta.id': run.robotMetaId }, raw: true }); + const plainRun = run.toJSON(); + + const recording = await Robot.findOne({ where: { 'recording_meta.id': plainRun.robotMetaId }, raw: true }); if (!recording) { return res.status(404).send(false); } // interpret the run in active browser - const browser = browserPool.getRemoteBrowser(run.browserId); + const browser = browserPool.getRemoteBrowser(plainRun.browserId); const currentPage = browser?.getCurrentPage(); if (browser && currentPage) { const interpretationInfo = await browser.interpreter.InterpretRecording( - recording.recording, currentPage, run.interpreterSettings); - await destroyRemoteBrowser(run.browserId); + recording.recording, currentPage, plainRun.interpreterSettings); + await destroyRemoteBrowser(plainRun.browserId); await run.update({ ...run, status: 'success', finishedAt: new Date().toLocaleString(), - browserId: run.browserId, + browserId: plainRun.browserId, log: interpretationInfo.log.join('\n'), serializableOutput: interpretationInfo.serializableOutput, binaryOutput: interpretationInfo.binaryOutput, }); googleSheetUpdateTasks[req.params.id] = { - name: run.name, - runId: run.runId, + name: plainRun.name, + runId: plainRun.runId, status: 'pending', retries: 5, }; @@ -351,7 +353,7 @@ router.put('/schedule/:fileName/', requireSignIn, async (req, res) => { router.post('/runs/abort/:id', requireSignIn, async (req, res) => { try { console.log(`Params for POST /runs/abort/:id`, req.params.id) - const run = await Run.findOne({ where: { runId: req.params.id }, raw: true }); + const run = await Run.findOne({ where: { runId: req.params.id }}); if (!run) { return res.status(404).send(false); }