1
0
Fork 0
mirror of synced 2024-06-29 11:40:45 +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); throw new Exception('Function not found', 404);
} }
$original = $function->getAttribute('schedule', '');
$cron = (!empty($function->getAttribute('tag', null)) && !empty($schedule)) ? CronExpression::factory($schedule) : null; $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; $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); throw new Exception('Failed saving function to DB', 500);
} }
if ($next) { if ($next && $schedule !== $original) {
ResqueScheduler::enqueueAt($next, 'v1-functions', 'FunctionsV1', [ ResqueScheduler::enqueueAt($next, 'v1-functions', 'FunctionsV1', [
'projectId' => $project->getId(), 'projectId' => $project->getId(),
'functionId' => $function->getId(), 'functionId' => $function->getId(),
@ -358,8 +359,9 @@ App::patch('/v1/functions/:functionId/tag')
} }
$schedule = $function->getAttribute('schedule', ''); $schedule = $function->getAttribute('schedule', '');
$cron = (empty($function->getAttribute('tag') && !empty($schedule))) ? CronExpression::factory($schedule) : null; var_dump($schedule);
$next = (empty($function->getAttribute('tag') && !empty($schedule))) ? $cron->getNextRunDate()->format('U') : null; $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(), [ $function = $projectDB->updateDocument(array_merge($function->getArrayCopy(), [
'tag' => $tag->getId(), 'tag' => $tag->getId(),

View file

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