chore: revert scheduling user id logic
This commit is contained in:
@@ -300,7 +300,7 @@ router.put("/sdk/robots/:id", requireAPIKey, async (req: AuthenticatedRequest, r
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await scheduleWorkflow(robotId, cronExpression, timezone);
|
await scheduleWorkflow(robotId, req.user.id, cronExpression, timezone);
|
||||||
} catch (scheduleError: any) {
|
} catch (scheduleError: any) {
|
||||||
logger.error(`[SDK] Failed to schedule workflow for robot ${robotId}: ${scheduleError.message}`);
|
logger.error(`[SDK] Failed to schedule workflow for robot ${robotId}: ${scheduleError.message}`);
|
||||||
return res.status(500).json({
|
return res.status(500).json({
|
||||||
|
|||||||
@@ -894,7 +894,7 @@ router.put('/schedule/:id/', requireSignIn, async (req: AuthenticatedRequest, re
|
|||||||
logger.log('warn', `Failed to cancel existing schedule for robot ${id}: ${cancelError}`);
|
logger.log('warn', `Failed to cancel existing schedule for robot ${id}: ${cancelError}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await scheduleWorkflow(id, cronExpression, timezone);
|
await scheduleWorkflow(id, req.user.id, cronExpression, timezone);
|
||||||
|
|
||||||
const nextRunAt = computeNextRun(cronExpression, timezone);
|
const nextRunAt = computeNextRun(cronExpression, timezone);
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
import { pgBossClient } from './pgboss';
|
import { pgBossClient } from './pgboss';
|
||||||
|
import { registerWorkerForQueue } from '../schedule-worker';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function to schedule a cron job using PgBoss
|
* Utility function to schedule a cron job using PgBoss
|
||||||
@@ -13,7 +14,7 @@ import { pgBossClient } from './pgboss';
|
|||||||
* @param cronExpression The cron expression for scheduling
|
* @param cronExpression The cron expression for scheduling
|
||||||
* @param timezone The timezone for the cron expression
|
* @param timezone The timezone for the cron expression
|
||||||
*/
|
*/
|
||||||
export async function scheduleWorkflow(id: string, cronExpression: string, timezone: string): Promise<void> {
|
export async function scheduleWorkflow(id: string, userId: string, cronExpression: string, timezone: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const runId = uuid();
|
const runId = uuid();
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ export async function scheduleWorkflow(id: string, cronExpression: string, timez
|
|||||||
await pgBossClient.createQueue(queueName);
|
await pgBossClient.createQueue(queueName);
|
||||||
|
|
||||||
await pgBossClient.schedule(queueName, cronExpression,
|
await pgBossClient.schedule(queueName, cronExpression,
|
||||||
{ id, runId },
|
{ id, runId, userId },
|
||||||
{ tz: timezone }
|
{ tz: timezone }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user