1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

Remove Search and add resourceType to indexes

This commit is contained in:
Bradley Schofield 2022-01-31 11:36:22 +00:00
parent 8e639d4f5f
commit d2ec314ef0
3 changed files with 10 additions and 87 deletions

View file

@ -2012,6 +2012,13 @@ $collections = [
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => '_key_resource_type',
'type' => Database::INDEX_KEY,
'attributes' => ['resourceType'],
'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => '_key_search',
'type' => Database::INDEX_FULLTEXT,
@ -2147,18 +2154,7 @@ $collections = [
'default' => '',
'array' => false,
'filters' => [],
],
[
'$id' => 'search',
'type' => Database::VAR_STRING,
'format' => '',
'size' => 16384,
'signed' => true,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
]
],
'indexes' => [
[

View file

@ -1052,77 +1052,6 @@ App::get('/v1/functions/:functionId/executions/:executionId')
$response->dynamic($execution, Response::MODEL_EXECUTION);
});
App::get('/v1/builds')
->groups(['api', 'functions'])
->desc('List Builds')
->label('scope', 'functions.read')
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'builds')
->label('sdk.description', '/docs/references/functions/list-builds.md')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_BUILD_LIST)
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
->param('limit', 25, new Range(0, 100), 'Maximum number of builds to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true)
->param('offset', 0, new Range(0, APP_LIMIT_COUNT), 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true)
->param('cursor', '', new UID(), 'ID of the function used as the starting point for the query, excluding the function itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true)
->param('cursorDirection', Database::CURSOR_AFTER, new WhiteList([Database::CURSOR_AFTER, Database::CURSOR_BEFORE]), 'Direction of the cursor.', true)
->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true)
->inject('response')
->inject('dbForProject')
->action(function ($search, $limit, $offset, $cursor, $cursorDirection, $orderType, $response, $dbForProject) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Database\Database $dbForProject */
if (!empty($cursor)) {
$cursorFunction = $dbForProject->getDocument('builds', $cursor);
if ($cursorFunction->isEmpty()) {
throw new Exception("Build '{$cursor}' for the 'cursor' value not found.", 400);
}
}
$queries = [];
if (!empty($search)) {
$queries[] = new Query('search', Query::TYPE_SEARCH, [$search]);
}
$response->dynamic(new Document([
'builds' => $dbForProject->find('builds', $queries, $limit, $offset, [], [$orderType], $cursorFunction ?? null, $cursorDirection),
'sum' => $dbForProject->count('builds', $queries, APP_LIMIT_COUNT),
]), Response::MODEL_BUILD_LIST);
});
App::get('/v1/builds/:buildId')
->groups(['api', 'functions'])
->desc('Get Build')
->label('scope', 'execution.read')
->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT])
->label('sdk.namespace', 'functions')
->label('sdk.method', 'getBuild')
->label('sdk.description', '/docs/references/functions/get-build.md')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_BUILD)
->param('buildId', '', new UID(), 'Build unique ID.')
->inject('response')
->inject('dbForProject')
->action(function ($buildId, $response, $dbForProject) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\Database\Database $dbForProject */
$build = Authorization::skip(function () use ($dbForProject, $buildId) {
return $dbForProject->getDocument('builds', $buildId);
});
if ($build->isEmpty()) {
throw new Exception('Build not found', 404);
}
$response->dynamic($build, Response::MODEL_BUILD);
});
App::post('/v1/builds/:buildId')
->groups(['api', 'functions'])
->desc('Retry Build')

View file

@ -420,8 +420,7 @@ function execute(string $trigger, string $projectId, string $executionId, string
'stdout' => '',
'stderr' => '',
'endTime' => 0,
'duration' => 0,
'search' => implode(' ', [$deployment->getId(), $buildId]),
'duration' => 0
]));
$deployment->setAttribute('buildId', $buildId);
@ -1113,8 +1112,7 @@ App::post('/v1/deployment')
'stdout' => '',
'stderr' => '',
'endTime' => 0,
'duration' => 0,
'search' => implode(' ', [$deployment->getId(), $buildId])
'duration' => 0
]));
$deployment->setAttribute('buildId', $buildId);