From 73a19614e1d949920bb01d044a6d52e7a497a240 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sat, 2 Jul 2022 17:38:53 +0300 Subject: [PATCH] functions api --- app/controllers/api/functions.php | 4 +--- app/workers/functions.php | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 2ab59d2e8f..a46fe2c19a 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -945,9 +945,7 @@ App::post('/v1/functions/:functionId/executions') $execution->setAttribute('stderr', $executionResponse['stderr']); $execution->setAttribute('time', $executionResponse['time']); } catch (\Throwable $th) { - $created = new DateTime($execution->getCreatedAt()); - $now = Database::getCurrentDateTimeObject(); - $interval = $now->diff($created); + $interval = (new DateTime())->diff(new DateTime($execution->getCreatedAt())); $execution ->setAttribute('time', (float)$interval->format('%s.%f')) ->setAttribute('status', 'failed') diff --git a/app/workers/functions.php b/app/workers/functions.php index 90f12b895e..74304a749d 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -296,9 +296,7 @@ class FunctionsV1 extends Worker ->setAttribute('stderr', $executionResponse['stderr']) ->setAttribute('time', $executionResponse['time']); } catch (\Throwable $th) { - $created = new DateTime($execution->getCreatedAt()); - $now = Database::getCurrentDateTimeObject(); - $interval = $now->diff($created); + $interval = (new DateTime())->diff(new DateTime($execution->getCreatedAt())); $execution ->setAttribute('time', (float)$interval->format('%s.%f')) ->setAttribute('status', 'failed')