From cff5bab40389f2f12531a68fdde7e976e44a7b87 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sat, 2 Jul 2022 17:25:44 +0300 Subject: [PATCH] functions api --- app/controllers/api/functions.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index e464fb7929..2ab59d2e8f 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -925,7 +925,6 @@ App::post('/v1/functions/:functionId/executions') /** Execute function */ $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); - $executionResponse = []; try { $executionResponse = $executor->createExecution( projectId: $project->getId(), @@ -946,12 +945,14 @@ App::post('/v1/functions/:functionId/executions') $execution->setAttribute('stderr', $executionResponse['stderr']); $execution->setAttribute('time', $executionResponse['time']); } catch (\Throwable $th) { - $endtime = \microtime(true); - $time = $endtime - $execution->getCreatedAt(); - $execution->setAttribute('time', $time); - $execution->setAttribute('status', 'failed'); - $execution->setAttribute('statusCode', $th->getCode()); - $execution->setAttribute('stderr', $th->getMessage()); + $created = new DateTime($execution->getCreatedAt()); + $now = Database::getCurrentDateTimeObject(); + $interval = $now->diff($created); + $execution + ->setAttribute('time', (float)$interval->format('%s.%f')) + ->setAttribute('status', 'failed') + ->setAttribute('statusCode', $th->getCode()) + ->setAttribute('stderr', $th->getMessage()); Console::error($th->getMessage()); }