Create execution even when logging is disabled

This commit is contained in:
Khushboo Verma 2024-06-28 19:51:33 +05:30
parent e5fd3619f7
commit 66c761b73e
2 changed files with 8 additions and 17 deletions

View file

@ -1702,6 +1702,7 @@ App::post('/v1/functions/:functionId/executions')
} }
$executionId = ID::unique(); $executionId = ID::unique();
var_dump("creating execution document");
$execution = new Document([ $execution = new Document([
'$id' => $executionId, '$id' => $executionId,
@ -1729,10 +1730,7 @@ App::post('/v1/functions/:functionId/executions')
->setContext('function', $function); ->setContext('function', $function);
if ($async) { if ($async) {
if ($function->getAttribute('logging')) { $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
/** @var Document $execution */
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
}
$queueForFunctions $queueForFunctions
->setType('http') ->setType('http')
@ -1850,10 +1848,7 @@ App::post('/v1/functions/:functionId/executions')
; ;
} }
if ($function->getAttribute('logging')) { $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
/** @var Document $execution */
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution));
}
$roles = Authorization::getRoles(); $roles = Authorization::getRoles();
$isPrivilegedUser = Auth::isPrivilegedUser($roles); $isPrivilegedUser = Auth::isPrivilegedUser($roles);

View file

@ -328,9 +328,7 @@ class Functions extends Action
'search' => implode(' ', [$functionId, $executionId]), 'search' => implode(' ', [$functionId, $executionId]),
]); ]);
if ($function->getAttribute('logging')) { $execution = $dbForProject->createDocument('executions', $execution);
$execution = $dbForProject->createDocument('executions', $execution);
}
// TODO: @Meldiron Trigger executions.create event here // TODO: @Meldiron Trigger executions.create event here
@ -342,9 +340,7 @@ class Functions extends Action
if ($execution->getAttribute('status') !== 'processing') { if ($execution->getAttribute('status') !== 'processing') {
$execution->setAttribute('status', 'processing'); $execution->setAttribute('status', 'processing');
if ($function->getAttribute('logging')) { $execution = $dbForProject->updateDocument('executions', $executionId, $execution);
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
}
} }
$durationStart = \microtime(true); $durationStart = \microtime(true);
@ -455,9 +451,9 @@ class Functions extends Action
; ;
} }
if ($function->getAttribute('logging')) {
$execution = $dbForProject->updateDocument('executions', $executionId, $execution); $execution = $dbForProject->updateDocument('executions', $executionId, $execution);
}
/** Trigger Webhook */ /** Trigger Webhook */
$executionModel = new Execution(); $executionModel = new Execution();
$queueForEvents $queueForEvents