1
0
Fork 0
mirror of synced 2024-06-26 18:20:43 +12:00

Some minor fixes

This commit is contained in:
Eldad Fux 2021-01-17 02:07:43 +02:00
parent 47f5e871ba
commit f16113dbb3
2 changed files with 9 additions and 3 deletions

View file

@ -293,6 +293,7 @@ App::put('/v1/functions/:functionId')
throw new Exception('Function not found', 404);
}
$original = $function->getAttribute('schedule', '');
$cron = (!empty($function->getAttribute('tag', null)) && !empty($schedule)) ? CronExpression::factory($schedule) : null;
$next = (!empty($function->getAttribute('tag', null)) && !empty($schedule)) ? $cron->getNextRunDate()->format('U') : null;
@ -313,7 +314,7 @@ App::put('/v1/functions/:functionId')
throw new Exception('Failed saving function to DB', 500);
}
if ($next) {
if ($next && $schedule !== $original) {
ResqueScheduler::enqueueAt($next, 'v1-functions', 'FunctionsV1', [
'projectId' => $project->getId(),
'functionId' => $function->getId(),
@ -358,8 +359,9 @@ App::patch('/v1/functions/:functionId/tag')
}
$schedule = $function->getAttribute('schedule', '');
$cron = (empty($function->getAttribute('tag') && !empty($schedule))) ? CronExpression::factory($schedule) : null;
$next = (empty($function->getAttribute('tag') && !empty($schedule))) ? $cron->getNextRunDate()->format('U') : null;
var_dump($schedule);
$cron = (empty($function->getAttribute('tag')) && !empty($schedule)) ? CronExpression::factory($schedule) : null;
$next = (empty($function->getAttribute('tag')) && !empty($schedule)) ? $cron->getNextRunDate()->format('U') : null;
$function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [
'tag' => $tag->getId(),

View file

@ -226,10 +226,14 @@ class FunctionsV1
->setAttribute('schedulePrevious', \time())
;
Authorization::disable();
$function = $database->updateDocument(array_merge($function->getArrayCopy(), [
'scheduleNext' => $next,
]));
Authorization::reset();
ResqueScheduler::enqueueAt($next, 'v1-functions', 'FunctionsV1', [
'projectId' => $projectId,
'functionId' => $function->getId(),