feat: pass recording id to run id

This commit is contained in:
karishmas6
2024-10-08 23:25:24 +05:30
parent 7db34bd663
commit 4b326784e1

View File

@@ -11,7 +11,7 @@ import cron from 'node-cron';
import { googleSheetUpdateTasks, processGoogleSheetUpdates } from '../workflow-management/integrations/gsheet'; import { googleSheetUpdateTasks, processGoogleSheetUpdates } from '../workflow-management/integrations/gsheet';
import { getDecryptedProxyConfig } from './proxy'; import { getDecryptedProxyConfig } from './proxy';
import { requireSignIn } from '../middlewares/auth'; import { requireSignIn } from '../middlewares/auth';
import { workflowQueue } from '../worker'; // import { workflowQueue } from '../worker';
// todo: move from here // todo: move from here
const getRecordingByFileName = async (fileName: string): Promise<any | null> => { const getRecordingByFileName = async (fileName: string): Promise<any | null> => {
@@ -96,7 +96,8 @@ router.delete('/runs/:fileName', requireSignIn, async (req, res) => {
router.put('/runs/:fileName', requireSignIn, async (req, res) => { router.put('/runs/:fileName', requireSignIn, async (req, res) => {
try { try {
const recording = await getRecordingByFileName(req.params.fileName); const recording = await getRecordingByFileName(req.params.fileName);
if (!recording || !recording.recordingId) {
if (!recording || !recording.recording_meta || !recording.recording_meta.id) {
return res.status(404).send({ error: 'Recording not found' }); return res.status(404).send({ error: 'Recording not found' });
} }
@@ -126,7 +127,7 @@ router.put('/runs/:fileName', requireSignIn, async (req, res) => {
const run_meta = { const run_meta = {
status: 'RUNNING', status: 'RUNNING',
name: req.params.fileName, name: req.params.fileName,
recordingId: recording.id, recordingId: recording.recording_meta.id,
startedAt: new Date().toLocaleString(), startedAt: new Date().toLocaleString(),
finishedAt: '', finishedAt: '',
browserId: id, browserId: id,
@@ -281,16 +282,16 @@ router.put('/schedule/:fileName/', requireSignIn, async (req, res) => {
const runId = uuid(); const runId = uuid();
await workflowQueue.add( // await workflowQueue.add(
'run workflow', // 'run workflow',
{ fileName, runId }, // { fileName, runId },
{ // {
repeat: { // repeat: {
pattern: cronExpression, // pattern: cronExpression,
tz: timezone // tz: timezone
} // }
} // }
); // );
res.status(200).json({ res.status(200).json({
message: 'success', message: 'success',