mirror of
https://github.com/appwrite/appwrite
synced 2026-05-06 06:48:22 +00:00
Merge branch 'cl-1.4.x' into 1.4.x
This commit is contained in:
commit
920d2b2db3
6 changed files with 72 additions and 32 deletions
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
|
|
@ -16,7 +16,7 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 2
|
||||
submodules: recursive
|
||||
ref: master
|
||||
ref: cl-1.4.x
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
|
|
|
|||
|
|
@ -1708,7 +1708,8 @@ App::post('/v1/functions/:functionId/executions')
|
|||
path: $path,
|
||||
method: $method,
|
||||
headers: $headers,
|
||||
runtimeEntrypoint: $command
|
||||
runtimeEntrypoint: $command,
|
||||
requestTimeout: 30
|
||||
);
|
||||
|
||||
$headersFiltered = [];
|
||||
|
|
|
|||
|
|
@ -92,16 +92,17 @@ App::post('/v1/projects')
|
|||
|
||||
$projectId = ($projectId == 'unique()') ? ID::unique() : $projectId;
|
||||
|
||||
$backups['database_db_fra1_02'] = ['from' => '7:30', 'to' => '8:15'];
|
||||
$backups['database_db_fra1_03'] = ['from' => '10:30', 'to' => '11:15'];
|
||||
$backups['database_db_fra1_04'] = ['from' => '13:30', 'to' => '14:15'];
|
||||
$backups['database_db_fra1_05'] = ['from' => '4:30', 'to' => '5:15'];
|
||||
$backups['database_db_fra1_06'] = ['from' => '16:30', 'to' => '17:15'];
|
||||
$backups['database_db_fra1_v14x_02'] = ['from' => '7:30', 'to' => '8:15'];
|
||||
$backups['database_db_fra1_v14x_03'] = ['from' => '10:30', 'to' => '11:15'];
|
||||
$backups['database_db_fra1_v14x_04'] = ['from' => '13:30', 'to' => '14:15'];
|
||||
$backups['database_db_fra1_v14x_05'] = ['from' => '4:30', 'to' => '5:15'];
|
||||
$backups['database_db_fra1_v14x_06'] = ['from' => '16:30', 'to' => '17:15'];
|
||||
$backups['database_db_fra1_v14x_07'] = ['from' => '19:30', 'to' => '20:15'];
|
||||
|
||||
$databases = Config::getParam('pools-database', []);
|
||||
|
||||
/**
|
||||
* Extract db from list while backing
|
||||
* Remove databases from the list that are currently undergoing an backup
|
||||
*/
|
||||
if (count($databases) > 1) {
|
||||
$now = new \DateTime();
|
||||
|
|
@ -120,7 +121,9 @@ App::post('/v1/projects')
|
|||
}
|
||||
}
|
||||
|
||||
if ($index = array_search('database_db_fra1_06', $databases)) {
|
||||
$databaseOverride = App::getEnv('_APP_DATABASE_OVERRIDE', null);
|
||||
$index = array_search($databaseOverride, $databases);
|
||||
if ($index) {
|
||||
$database = $databases[$index];
|
||||
} else {
|
||||
$database = $databases[array_rand($databases)];
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques
|
|||
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
// \curl_setopt($ch, CURLOPT_HEADER, true);
|
||||
\curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
\curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
|
||||
$executionResponse = \curl_exec($ch);
|
||||
$statusCode = \curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
|
|
|||
|
|
@ -97,6 +97,32 @@ class Hamster extends Action
|
|||
/** Get Project Name */
|
||||
$statsPerProject['project_name'] = $project->getAttribute('name');
|
||||
|
||||
/** Total Project Variables */
|
||||
$statsPerProject['custom_variables'] = $dbForProject->count('variables', [], APP_LIMIT_COUNT);
|
||||
|
||||
/** Total Migrations */
|
||||
$statsPerProject['custom_migrations'] = $dbForProject->count('migrations', [], APP_LIMIT_COUNT);
|
||||
|
||||
/** Get Custom SMTP */
|
||||
$smtp = $project->getAttribute('smtp', null);
|
||||
if ($smtp) {
|
||||
$statsPerProject['custom_smtp_status'] = $smtp['enabled'] === true ? 'enabled' : 'disabled';
|
||||
|
||||
/** Get Custom Templates Count */
|
||||
$templates = array_keys($project->getAttribute('templates', []));
|
||||
$statsPerProject['custom_email_templates'] = array_filter($templates, function ($template) {
|
||||
return str_contains($template, 'email');
|
||||
});
|
||||
$statsPerProject['custom_sms_templates'] = array_filter($templates, function ($template) {
|
||||
return str_contains($template, 'sms');
|
||||
});
|
||||
}
|
||||
|
||||
/** Get total relationship attributes */
|
||||
$statsPerProject['custom_relationship_attributes'] = $dbForProject->count('attributes', [
|
||||
Query::equal('type', ['relationship'])
|
||||
], APP_LIMIT_COUNT);
|
||||
|
||||
/** Get Total Functions */
|
||||
$statsPerProject['custom_functions'] = $dbForProject->count('functions', [], APP_LIMIT_COUNT);
|
||||
|
||||
|
|
@ -108,6 +134,17 @@ class Hamster extends Action
|
|||
|
||||
/** Get Total Deployments */
|
||||
$statsPerProject['custom_deployments'] = $dbForProject->count('deployments', [], APP_LIMIT_COUNT);
|
||||
$statsPerProject['custom_deployments_manual'] = $dbForProject->count('deployments', [
|
||||
Query::equal('type', ['manual'])
|
||||
], APP_LIMIT_COUNT);
|
||||
$statsPerProject['custom_deployments_git'] = $dbForProject->count('deployments', [
|
||||
Query::equal('type', ['vcs'])
|
||||
], APP_LIMIT_COUNT);
|
||||
|
||||
/** Get VCS repos connected */
|
||||
$statsPerProject['custom_vcs_repositories'] = $dbForConsole->count('repositories', [
|
||||
Query::equal('projectInternalId', [$project->getInternalId()])
|
||||
], APP_LIMIT_COUNT);
|
||||
|
||||
/** Get Total Teams */
|
||||
$statsPerProject['custom_teams'] = $dbForProject->count('teams', [], APP_LIMIT_COUNT);
|
||||
|
|
@ -132,19 +169,16 @@ class Hamster extends Action
|
|||
throw new Exception('Membership not found. Skipping project : ' . $project->getId());
|
||||
}
|
||||
|
||||
$userInternalId = $membership->getAttribute('userInternalId', null);
|
||||
if ($userInternalId) {
|
||||
$user = $dbForConsole->findOne('users', [
|
||||
Query::equal('_id', [$userInternalId]),
|
||||
]);
|
||||
|
||||
$userId = $membership->getAttribute('userId', null);
|
||||
if ($userId) {
|
||||
$user = $dbForConsole->getDocument('users', $userId);
|
||||
$statsPerProject['email'] = $user->getAttribute('email', null);
|
||||
$statsPerProject['name'] = $user->getAttribute('name', null);
|
||||
}
|
||||
}
|
||||
|
||||
/** Get Domains */
|
||||
$statsPerProject['custom_domains'] = $dbForConsole->count('domains', [
|
||||
$statsPerProject['custom_domains'] = $dbForConsole->count('rules', [
|
||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||
Query::limit(APP_LIMIT_COUNT)
|
||||
]);
|
||||
|
|
@ -234,15 +268,16 @@ class Hamster extends Action
|
|||
if (!$res) {
|
||||
Console::error('Failed to create user profile for project: ' . $project->getId());
|
||||
}
|
||||
}
|
||||
|
||||
$event = new Event();
|
||||
$event
|
||||
->setName('Project Daily Usage')
|
||||
->setProps($statsPerProject);
|
||||
$res = $this->mixpanel->createEvent($event);
|
||||
if (!$res) {
|
||||
Console::error('Failed to create event for project: ' . $project->getId());
|
||||
}
|
||||
$event = new Event();
|
||||
$event
|
||||
->setName('Project Daily Usage')
|
||||
->setProps($statsPerProject);
|
||||
$res = $this->mixpanel->createEvent($event);
|
||||
|
||||
if (!$res) {
|
||||
Console::error('Failed to create event for project: ' . $project->getId());
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Console::error('Failed to send stats for project: ' . $project->getId());
|
||||
|
|
@ -362,12 +397,9 @@ class Hamster extends Action
|
|||
throw new Exception('Membership not found. Skipping organization : ' . $document->getId());
|
||||
}
|
||||
|
||||
$userInternalId = $membership->getAttribute('userInternalId', null);
|
||||
if ($userInternalId) {
|
||||
$user = $dbForConsole->findOne('users', [
|
||||
Query::equal('_id', [$userInternalId]),
|
||||
]);
|
||||
|
||||
$userId = $membership->getAttribute('userId', null);
|
||||
if ($userId) {
|
||||
$user = $dbForConsole->getDocument('users', $userId);
|
||||
$statsPerOrganization['email'] = $user->getAttribute('email', null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ class Executor
|
|||
string $method,
|
||||
array $headers,
|
||||
string $runtimeEntrypoint = null,
|
||||
int $requestTimeout = null
|
||||
) {
|
||||
if (empty($headers['host'])) {
|
||||
$headers['host'] = App::getEnv('_APP_DOMAIN', '');
|
||||
|
|
@ -204,9 +205,11 @@ class Executor
|
|||
|
||||
// Safety timeout. Executor has timeout, and open runtime has soft timeout.
|
||||
// This one shouldn't really happen, but prevents from unexpected networking behaviours.
|
||||
$timeout = $timeout + 15;
|
||||
if ($requestTimeout == null) {
|
||||
$requestTimeout = $timeout + 15;
|
||||
}
|
||||
|
||||
$response = $this->call(self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $timeout);
|
||||
$response = $this->call(self::METHOD_POST, $route, [ 'x-opr-runtime-id' => $runtimeId ], $params, true, $requestTimeout);
|
||||
|
||||
$status = $response['headers']['status-code'];
|
||||
if ($status >= 400) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue