1
0
Fork 0
mirror of synced 2024-09-30 17:26:48 +13:00

PR review changes

This commit is contained in:
Matej Bačo 2022-08-30 12:30:52 +00:00
parent e6ccfb6dd7
commit 1e95346205
4 changed files with 22 additions and 30 deletions

View file

@ -85,8 +85,7 @@ App::post('/v1/functions')
'schedulePrevious' => null, 'schedulePrevious' => null,
'scheduleNext' => null, 'scheduleNext' => null,
'timeout' => $timeout, 'timeout' => $timeout,
'search' => implode(' ', [$functionId, $name, $runtime]), 'search' => implode(' ', [$functionId, $name, $runtime])
'vars' => null
])); ]));
$eventsInstance->setParam('functionId', $function->getId()); $eventsInstance->setParam('functionId', $function->getId());
@ -1048,13 +1047,10 @@ App::post('/v1/functions/:functionId/executions')
return $response->dynamic($execution, Response::MODEL_EXECUTION); return $response->dynamic($execution, Response::MODEL_EXECUTION);
} }
$vars = []; $vars = array_reduce($function['vars'] ?? [], function (array $carry, Document $var) {
$carry[$var->getAttribute('key')] = $var->getAttribute('value');
$variables = $function['vars']; return $carry;
}, []);
foreach ($variables as $variable) {
$vars[$variable['key']] = $variable['value'];
}
$vars = \array_merge($vars, [ $vars = \array_merge($vars, [
'APPWRITE_FUNCTION_ID' => $function->getId(), 'APPWRITE_FUNCTION_ID' => $function->getId(),
@ -1380,8 +1376,8 @@ App::get('/v1/functions/:functionId/variables')
} }
// Get cursor document if there was a cursor query // Get cursor document if there was a cursor query
$cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE));
if ($cursor !== null) { if ($cursor) {
/** @var Query $cursor */ /** @var Query $cursor */
$variableId = $cursor->getValue(); $variableId = $cursor->getValue();
$cursorDocument = $dbForProject->getDocument('variables', $variableId); $cursorDocument = $dbForProject->getDocument('variables', $variableId);
@ -1424,7 +1420,7 @@ App::get('/v1/functions/:functionId/variables/:variableId')
} }
$variable = $dbForProject->findOne('variables', [ $variable = $dbForProject->findOne('variables', [
Query::equal('_uid', [$variableId]), Query::equal('$id', [$variableId]),
Query::equal('functionInternalId', [$function->getInternalId()]), Query::equal('functionInternalId', [$function->getInternalId()]),
]); ]);
@ -1464,7 +1460,7 @@ App::put('/v1/functions/:functionId/variables/:variableId')
} }
$variable = $dbForProject->findOne('variables', [ $variable = $dbForProject->findOne('variables', [
Query::equal('_uid', [$variableId]), Query::equal('$id', [$variableId]),
Query::equal('functionInternalId', [$function->getInternalId()]), Query::equal('functionInternalId', [$function->getInternalId()]),
]); ]);
@ -1511,7 +1507,7 @@ App::delete('/v1/functions/:functionId/variables/:variableId')
} }
$variable = $dbForProject->findOne('variables', [ $variable = $dbForProject->findOne('variables', [
Query::equal('_uid', [$variableId]), Query::equal('$id', [$variableId]),
Query::equal('functionInternalId', [$function->getInternalId()]), Query::equal('functionInternalId', [$function->getInternalId()]),
]); ]);

View file

@ -145,12 +145,11 @@ class BuildsV1 extends Worker
); );
$source = $deployment->getAttribute('path'); $source = $deployment->getAttribute('path');
$vars = [];
$variables = $function['vars'];
foreach ($variables as $variable) { $vars = array_reduce($function['vars'] ?? [], function (array $carry, Document $var) {
$vars[$variable['key']] = $variable['value']; $carry[$var->getAttribute('key')] = $var->getAttribute('value');
} return $carry;
}, []);
$baseImage = $runtime['image']; $baseImage = $runtime['image'];

View file

@ -259,13 +259,10 @@ class FunctionsV1 extends Worker
$execution->setAttribute('status', 'processing'); $execution->setAttribute('status', 'processing');
$execution = $dbForProject->updateDocument('executions', $executionId, $execution); $execution = $dbForProject->updateDocument('executions', $executionId, $execution);
$vars = []; $vars = array_reduce($function['vars'] ?? [], function (array $carry, Document $var) {
$carry[$var->getAttribute('key')] = $var->getAttribute('value');
$variables = $function['vars']; return $carry;
}, []);
foreach ($variables as $variable) {
$vars[$variable['key']] = $variable['value'];
}
/** Collect environment variables */ /** Collect environment variables */
$vars = \array_merge($vars, [ $vars = \array_merge($vars, [

8
composer.lock generated
View file

@ -2841,12 +2841,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/appwrite/sdk-generator.git", "url": "https://github.com/appwrite/sdk-generator.git",
"reference": "bf05fc00755b9d27dac530669ca834f3ceb655ec" "reference": "6e630a62f522ac68a7056bebf81cd032c7a053ba"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/bf05fc00755b9d27dac530669ca834f3ceb655ec", "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/6e630a62f522ac68a7056bebf81cd032c7a053ba",
"reference": "bf05fc00755b9d27dac530669ca834f3ceb655ec", "reference": "6e630a62f522ac68a7056bebf81cd032c7a053ba",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2884,7 +2884,7 @@
"issues": "https://github.com/appwrite/sdk-generator/issues", "issues": "https://github.com/appwrite/sdk-generator/issues",
"source": "https://github.com/appwrite/sdk-generator/tree/master" "source": "https://github.com/appwrite/sdk-generator/tree/master"
}, },
"time": "2022-08-28T04:14:32+00:00" "time": "2022-08-29T10:43:33+00:00"
}, },
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",