mirror of
https://github.com/appwrite/appwrite
synced 2026-05-06 06:48:22 +00:00
Updated cancelled build duration
This commit is contained in:
parent
d233f1ac64
commit
97786a05ff
2 changed files with 12 additions and 27 deletions
|
|
@ -1550,23 +1550,11 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId/build')
|
|||
if (\in_array($build->getAttribute('status'), ['ready', 'failed'])) {
|
||||
throw new Exception(Exception::BUILD_ALREADY_COMPLETED);
|
||||
}
|
||||
$startTime = new \DateTime($build->getAttribute('startTime'));
|
||||
$endTime = new \DateTime();
|
||||
$interval = $startTime->diff($endTime);
|
||||
|
||||
$minuteInSeconds = 60;
|
||||
$hourInSeconds = $minuteInSeconds * 60;
|
||||
$dayInSeconds = $hourInSeconds * 24;
|
||||
$monthInSeconds = $dayInSeconds * 30;
|
||||
$yearsInSeconds = $monthInSeconds * 12;
|
||||
|
||||
$duration = 0;
|
||||
$duration += $interval->s;
|
||||
$duration += $interval->i * $minuteInSeconds;
|
||||
$duration += $interval->h * $hourInSeconds;
|
||||
$duration += $interval->d * $dayInSeconds;
|
||||
$duration += $interval->m * $monthInSeconds;
|
||||
$duration += $interval->y * $yearsInSeconds;
|
||||
$startTime = $build->getAttribute('startTime');
|
||||
$endTime = DateTime::now();
|
||||
$startTime = strtotime($startTime);
|
||||
$endTime = strtotime($endTime);
|
||||
$duration = $endTime - $startTime;
|
||||
|
||||
$build = $dbForProject->updateDocument('builds', $build->getId(), $build->setAttributes([
|
||||
'endTime' => DateTime::now(),
|
||||
|
|
|
|||
|
|
@ -184,6 +184,8 @@ class Builds extends Action
|
|||
} elseif ($build->getAttribute('status') === 'cancelled') {
|
||||
Console::info('Build has been cancelled');
|
||||
return;
|
||||
} else {
|
||||
$build = $dbForProject->getDocument('builds', $buildId);
|
||||
}
|
||||
|
||||
$source = $deployment->getAttribute('path', '');
|
||||
|
|
@ -224,8 +226,7 @@ class Builds extends Action
|
|||
$stderr = '';
|
||||
Console::execute('mkdir -p /tmp/builds/' . \escapeshellcmd($buildId), '', $stdout, $stderr);
|
||||
|
||||
$build = $dbForProject->getDocument('builds', $buildId);
|
||||
if ($build->getAttribute('status') === 'cancelled') {
|
||||
if ($dbForProject->getDocument('builds', $buildId)->getAttribute('status') === 'cancelled') {
|
||||
Console::info('Build has been cancelled');
|
||||
return;
|
||||
}
|
||||
|
|
@ -406,8 +407,7 @@ class Builds extends Action
|
|||
$response = null;
|
||||
$err = null;
|
||||
|
||||
$build = $dbForProject->getDocument('builds', $buildId);
|
||||
if ($build->getAttribute('status') === 'cancelled') {
|
||||
if ($dbForProject->getDocument('builds', $buildId)->getAttribute('status') === 'cancelled') {
|
||||
Console::info('Build has been cancelled');
|
||||
return;
|
||||
}
|
||||
|
|
@ -478,8 +478,7 @@ class Builds extends Action
|
|||
]);
|
||||
|
||||
if ($err) {
|
||||
$build = $dbForProject->getDocument('builds', $buildId);
|
||||
if ($build->getAttribute('status') === 'cancelled') {
|
||||
if ($dbForProject->getDocument('builds', $buildId)->getAttribute('status') === 'cancelled') {
|
||||
Console::info('Build has been cancelled');
|
||||
return;
|
||||
}
|
||||
|
|
@ -512,8 +511,7 @@ class Builds extends Action
|
|||
$function = $dbForProject->updateDocument('functions', $function->getId(), $function);
|
||||
}
|
||||
|
||||
$build = $dbForProject->getDocument('builds', $buildId);
|
||||
if ($build->getAttribute('status') === 'cancelled') {
|
||||
if ($dbForProject->getDocument('builds', $buildId)->getAttribute('status') === 'cancelled') {
|
||||
Console::info('Build has been cancelled');
|
||||
return;
|
||||
}
|
||||
|
|
@ -528,8 +526,7 @@ class Builds extends Action
|
|||
->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment')));
|
||||
Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule));
|
||||
} catch (\Throwable $th) {
|
||||
$build = $dbForProject->getDocument('builds', $buildId);
|
||||
if ($build->getAttribute('status') === 'cancelled') {
|
||||
if ($dbForProject->getDocument('builds', $buildId)->getAttribute('status') === 'cancelled') {
|
||||
Console::info('Build has been cancelled');
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue