1
0
Fork 0
mirror of synced 2024-07-08 16:06:02 +12:00

Merge pull request #5206 from appwrite/fix-schedules-functions

Fix schedules functions
This commit is contained in:
Christy Jacob 2023-03-20 23:01:21 +05:30 committed by GitHub
commit b5a1c2b2e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 32 deletions

@ -1 +1 @@
Subproject commit 39727607a036534a323101fea876cbe68b05f4f0 Subproject commit fae048b91787d0b372c13caf27f14fc8b780ef60

View file

@ -238,8 +238,8 @@ App::get('/v1/functions/:functionId/usage')
$stats = $usage = []; $stats = $usage = [];
$days = $periods[$range]; $days = $periods[$range];
$metrics = [ $metrics = [
str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS), str_replace(['{resourceType}', '{resourceInternalId}'], ['functions', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS),
str_replace(['{resourceType}', '{resourceInternalId}'], ['function', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE), str_replace(['{resourceType}', '{resourceInternalId}'], ['functions', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE),
str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS), str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS),
str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_STORAGE), str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_STORAGE),
str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_COMPUTE), str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_BUILDS_COMPUTE),

View file

@ -42,10 +42,12 @@ Server::setResource('execute', function () {
$user ??= new Document(); $user ??= new Document();
$functionId = $function->getId(); $functionId = $function->getId();
$functionInternalId = $function->getInternalId();
$deploymentId = $function->getAttribute('deployment', ''); $deploymentId = $function->getAttribute('deployment', '');
/** Check if deployment exists */ /** Check if deployment exists */
$deployment = $dbForProject->getDocument('deployments', $deploymentId); $deployment = $dbForProject->getDocument('deployments', $deploymentId);
$deploymentInternalId = $deployment->getInternalId();
if ($deployment->getAttribute('resourceId') !== $functionId) { if ($deployment->getAttribute('resourceId') !== $functionId) {
throw new Exception('Deployment not found. Create deployment before trying to execute a function'); throw new Exception('Deployment not found. Create deployment before trying to execute a function');
@ -82,6 +84,8 @@ Server::setResource('execute', function () {
'$id' => $executionId, '$id' => $executionId,
'$permissions' => $user->isEmpty() ? [] : [Permission::read(Role::user($user->getId()))], '$permissions' => $user->isEmpty() ? [] : [Permission::read(Role::user($user->getId()))],
'functionId' => $functionId, 'functionId' => $functionId,
'functionInternalId' => $functionInternalId,
'deploymentInternalId' => $deploymentInternalId,
'deploymentId' => $deploymentId, 'deploymentId' => $deploymentId,
'trigger' => $trigger, 'trigger' => $trigger,
'status' => 'waiting', 'status' => 'waiting',
@ -104,7 +108,7 @@ Server::setResource('execute', function () {
$queueForUsage $queueForUsage
->addMetric(METRIC_EXECUTIONS, 1) // per project ->addMetric(METRIC_EXECUTIONS, 1) // per project
->addMetric(str_replace('{functionInternalId}', $function->getId(), METRIC_FUNCTION_ID_EXECUTIONS), 1); // per function ->addMetric(str_replace('{functionInternalId}', $function->getInternalId(), METRIC_FUNCTION_ID_EXECUTIONS), 1); // per function
} }
$execution->setAttribute('status', 'processing'); $execution->setAttribute('status', 'processing');

57
composer.lock generated
View file

@ -2760,16 +2760,16 @@
}, },
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",
"version": "1.11.0", "version": "1.11.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/myclabs/DeepCopy.git", "url": "https://github.com/myclabs/DeepCopy.git",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2807,7 +2807,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/myclabs/DeepCopy/issues", "issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1"
}, },
"funding": [ "funding": [
{ {
@ -2815,20 +2815,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2022-03-03T13:19:32+00:00" "time": "2023-03-08T13:26:56+00:00"
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v4.15.3", "version": "v4.15.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039" "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/570e980a201d8ed0236b0a62ddf2c9cbb2034039", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6bb5176bc4af8bcb7d926f88718db9b96a2d4290",
"reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039", "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2869,9 +2869,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/nikic/PHP-Parser/issues", "issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.15.3" "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.4"
}, },
"time": "2023-01-16T22:05:37+00:00" "time": "2023-03-05T19:49:14+00:00"
}, },
{ {
"name": "phar-io/manifest", "name": "phar-io/manifest",
@ -3219,23 +3219,23 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "9.2.24", "version": "9.2.26",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "2cf940ebc6355a9d430462811b5aaa308b174bed" "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2cf940ebc6355a9d430462811b5aaa308b174bed", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/443bc6912c9bd5b409254a40f4b0f4ced7c80ea1",
"reference": "2cf940ebc6355a9d430462811b5aaa308b174bed", "reference": "443bc6912c9bd5b409254a40f4b0f4ced7c80ea1",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-dom": "*", "ext-dom": "*",
"ext-libxml": "*", "ext-libxml": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"nikic/php-parser": "^4.14", "nikic/php-parser": "^4.15",
"php": ">=7.3", "php": ">=7.3",
"phpunit/php-file-iterator": "^3.0.3", "phpunit/php-file-iterator": "^3.0.3",
"phpunit/php-text-template": "^2.0.2", "phpunit/php-text-template": "^2.0.2",
@ -3250,8 +3250,8 @@
"phpunit/phpunit": "^9.3" "phpunit/phpunit": "^9.3"
}, },
"suggest": { "suggest": {
"ext-pcov": "*", "ext-pcov": "PHP extension that provides line coverage",
"ext-xdebug": "*" "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
@ -3284,7 +3284,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.24" "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.26"
}, },
"funding": [ "funding": [
{ {
@ -3292,7 +3292,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-01-26T08:26:55+00:00" "time": "2023-03-06T12:58:08+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -4604,16 +4604,16 @@
}, },
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "3.7.1", "version": "3.7.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879",
"reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4649,14 +4649,15 @@
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
"keywords": [ "keywords": [
"phpcs", "phpcs",
"standards" "standards",
"static analysis"
], ],
"support": { "support": {
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
"source": "https://github.com/squizlabs/PHP_CodeSniffer", "source": "https://github.com/squizlabs/PHP_CodeSniffer",
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
}, },
"time": "2022-06-18T07:21:10+00:00" "time": "2023-02-22T23:07:41+00:00"
}, },
{ {
"name": "swoole/ide-helper", "name": "swoole/ide-helper",
@ -5067,5 +5068,5 @@
"platform-overrides": { "platform-overrides": {
"php": "8.0" "php": "8.0"
}, },
"plugin-api-version": "2.3.0" "plugin-api-version": "2.2.0"
} }