1
0
Fork 0
mirror of synced 2024-10-02 02:07:04 +13:00

Merge branch 'cl-1.4.x' into 1.4.x

This commit is contained in:
Torsten Dittmann 2023-10-10 11:59:24 +02:00 committed by GitHub
commit 920d2b2db3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 32 deletions

View file

@ -16,7 +16,7 @@ jobs:
with: with:
fetch-depth: 2 fetch-depth: 2
submodules: recursive submodules: recursive
ref: master ref: cl-1.4.x
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@v2

View file

@ -1708,7 +1708,8 @@ App::post('/v1/functions/:functionId/executions')
path: $path, path: $path,
method: $method, method: $method,
headers: $headers, headers: $headers,
runtimeEntrypoint: $command runtimeEntrypoint: $command,
requestTimeout: 30
); );
$headersFiltered = []; $headersFiltered = [];

View file

@ -92,16 +92,17 @@ App::post('/v1/projects')
$projectId = ($projectId == 'unique()') ? ID::unique() : $projectId; $projectId = ($projectId == 'unique()') ? ID::unique() : $projectId;
$backups['database_db_fra1_02'] = ['from' => '7:30', 'to' => '8:15']; $backups['database_db_fra1_v14x_02'] = ['from' => '7:30', 'to' => '8:15'];
$backups['database_db_fra1_03'] = ['from' => '10:30', 'to' => '11:15']; $backups['database_db_fra1_v14x_03'] = ['from' => '10:30', 'to' => '11:15'];
$backups['database_db_fra1_04'] = ['from' => '13:30', 'to' => '14:15']; $backups['database_db_fra1_v14x_04'] = ['from' => '13:30', 'to' => '14:15'];
$backups['database_db_fra1_05'] = ['from' => '4:30', 'to' => '5:15']; $backups['database_db_fra1_v14x_05'] = ['from' => '4:30', 'to' => '5:15'];
$backups['database_db_fra1_06'] = ['from' => '16:30', 'to' => '17: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', []); $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) { if (count($databases) > 1) {
$now = new \DateTime(); $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]; $database = $databases[$index];
} else { } else {
$database = $databases[array_rand($databases)]; $database = $databases[array_rand($databases)];

View file

@ -139,6 +139,7 @@ function router(App $utopia, Database $dbForConsole, SwooleRequest $swooleReques
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// \curl_setopt($ch, CURLOPT_HEADER, true); // \curl_setopt($ch, CURLOPT_HEADER, true);
\curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
\curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$executionResponse = \curl_exec($ch); $executionResponse = \curl_exec($ch);
$statusCode = \curl_getinfo($ch, CURLINFO_HTTP_CODE); $statusCode = \curl_getinfo($ch, CURLINFO_HTTP_CODE);

View file

@ -97,6 +97,32 @@ class Hamster extends Action
/** Get Project Name */ /** Get Project Name */
$statsPerProject['project_name'] = $project->getAttribute('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 */ /** Get Total Functions */
$statsPerProject['custom_functions'] = $dbForProject->count('functions', [], APP_LIMIT_COUNT); $statsPerProject['custom_functions'] = $dbForProject->count('functions', [], APP_LIMIT_COUNT);
@ -108,6 +134,17 @@ class Hamster extends Action
/** Get Total Deployments */ /** Get Total Deployments */
$statsPerProject['custom_deployments'] = $dbForProject->count('deployments', [], APP_LIMIT_COUNT); $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 */ /** Get Total Teams */
$statsPerProject['custom_teams'] = $dbForProject->count('teams', [], APP_LIMIT_COUNT); $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()); throw new Exception('Membership not found. Skipping project : ' . $project->getId());
} }
$userInternalId = $membership->getAttribute('userInternalId', null); $userId = $membership->getAttribute('userId', null);
if ($userInternalId) { if ($userId) {
$user = $dbForConsole->findOne('users', [ $user = $dbForConsole->getDocument('users', $userId);
Query::equal('_id', [$userInternalId]),
]);
$statsPerProject['email'] = $user->getAttribute('email', null); $statsPerProject['email'] = $user->getAttribute('email', null);
$statsPerProject['name'] = $user->getAttribute('name', null); $statsPerProject['name'] = $user->getAttribute('name', null);
} }
} }
/** Get Domains */ /** Get Domains */
$statsPerProject['custom_domains'] = $dbForConsole->count('domains', [ $statsPerProject['custom_domains'] = $dbForConsole->count('rules', [
Query::equal('projectInternalId', [$project->getInternalId()]), Query::equal('projectInternalId', [$project->getInternalId()]),
Query::limit(APP_LIMIT_COUNT) Query::limit(APP_LIMIT_COUNT)
]); ]);
@ -234,16 +268,17 @@ class Hamster extends Action
if (!$res) { if (!$res) {
Console::error('Failed to create user profile for project: ' . $project->getId()); Console::error('Failed to create user profile for project: ' . $project->getId());
} }
}
$event = new Event(); $event = new Event();
$event $event
->setName('Project Daily Usage') ->setName('Project Daily Usage')
->setProps($statsPerProject); ->setProps($statsPerProject);
$res = $this->mixpanel->createEvent($event); $res = $this->mixpanel->createEvent($event);
if (!$res) { if (!$res) {
Console::error('Failed to create event for project: ' . $project->getId()); Console::error('Failed to create event for project: ' . $project->getId());
} }
}
} catch (Exception $e) { } catch (Exception $e) {
Console::error('Failed to send stats for project: ' . $project->getId()); Console::error('Failed to send stats for project: ' . $project->getId());
Console::error($e->getMessage()); Console::error($e->getMessage());
@ -362,12 +397,9 @@ class Hamster extends Action
throw new Exception('Membership not found. Skipping organization : ' . $document->getId()); throw new Exception('Membership not found. Skipping organization : ' . $document->getId());
} }
$userInternalId = $membership->getAttribute('userInternalId', null); $userId = $membership->getAttribute('userId', null);
if ($userInternalId) { if ($userId) {
$user = $dbForConsole->findOne('users', [ $user = $dbForConsole->getDocument('users', $userId);
Query::equal('_id', [$userInternalId]),
]);
$statsPerOrganization['email'] = $user->getAttribute('email', null); $statsPerOrganization['email'] = $user->getAttribute('email', null);
} }

View file

@ -177,6 +177,7 @@ class Executor
string $method, string $method,
array $headers, array $headers,
string $runtimeEntrypoint = null, string $runtimeEntrypoint = null,
int $requestTimeout = null
) { ) {
if (empty($headers['host'])) { if (empty($headers['host'])) {
$headers['host'] = App::getEnv('_APP_DOMAIN', ''); $headers['host'] = App::getEnv('_APP_DOMAIN', '');
@ -204,9 +205,11 @@ class Executor
// Safety timeout. Executor has timeout, and open runtime has soft timeout. // Safety timeout. Executor has timeout, and open runtime has soft timeout.
// This one shouldn't really happen, but prevents from unexpected networking behaviours. // 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']; $status = $response['headers']['status-code'];
if ($status >= 400) { if ($status >= 400) {