Some minor fixes
This commit is contained in:
parent
47f5e871ba
commit
f16113dbb3
2 changed files with 9 additions and 3 deletions
|
@ -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(),
|
||||||
|
|
|
@ -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(),
|
||||||
|
|
Loading…
Reference in a new issue