This commit is contained in:
shimon 2024-10-07 11:06:08 +03:00
parent 424f24af04
commit fa513d6242
3 changed files with 42 additions and 1 deletions

View file

@ -88,7 +88,11 @@ App::post('/v1/projects')
->inject('hooks')
->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForConsole, Cache $cache, Group $pools, Hooks $hooks) {
$ctime = time();
var_dump("[".$region."] - Before getDocument('teams')");
$team = $dbForConsole->getDocument('teams', $teamId);
$diff = time() - $ctime;
var_dump("[".$region."] - After getDocument('teams') : " . $diff . " sec");
if ($team->isEmpty()) {
throw new Exception(Exception::TEAM_NOT_FOUND);
@ -145,6 +149,8 @@ App::post('/v1/projects')
}
try {
$ctime = time();
var_dump("[".$region."] - Before createDocument('projects')");
$project = $dbForConsole->createDocument('projects', new Document([
'$id' => $projectId,
'$permissions' => [
@ -178,6 +184,10 @@ App::post('/v1/projects')
'search' => implode(' ', [$projectId, $name]),
'database' => $dsn,
]));
$diff = time() - $ctime;
var_dump("[".$region."] - After createDocument('projects') : " . $diff . " sec");
} catch (Duplicate) {
throw new Exception(Exception::PROJECT_ALREADY_EXISTS);
}
@ -229,7 +239,12 @@ App::post('/v1/projects')
}, $collection['indexes']);
try {
$ctime = time();
var_dump("[".$region."] - Before createCollection('".$key."')");
$dbForProject->createCollection($key, $attributes, $indexes);
$diff = time() - $ctime;
var_dump("[".$region."] - After createCollection('".$key."') : " . $diff . " sec");
} catch (Duplicate) {
// Collection already exists
}

View file

@ -451,6 +451,9 @@ App::init()
->inject('queueForEvents')
->inject('queueForCertificates')
->action(function (App $utopia, SwooleRequest $swooleRequest, Request $request, Response $response, Document $console, Document $project, Database $dbForConsole, callable $getProjectDB, Locale $locale, array $localeCodes, array $clients, Reader $geodb, Usage $queueForUsage, Event $queueForEvents, Certificate $queueForCertificates) {
$ctime = time();
var_dump("[".$region."] - Before general first init hook");
/*
* Appwrite Router
*/
@ -655,6 +658,9 @@ App::init()
) {
throw new AppwriteException(AppwriteException::GENERAL_UNKNOWN_ORIGIN, $originValidator->getDescription());
}
$diff = time() - $ctime;
var_dump("[".$region."] - After general first init hook : " . $diff . " sec");
});
App::options()

View file

@ -162,6 +162,9 @@ App::init()
->inject('mode')
->inject('team')
->action(function (App $utopia, Request $request, Database $dbForConsole, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team) {
$ctime = time();
var_dump("[".$region."] - Before shared api first init hook");
$route = $utopia->getRoute();
if ($project->isEmpty()) {
@ -344,6 +347,8 @@ App::init()
throw new Exception(Exception::USER_MORE_FACTORS_REQUIRED);
}
}
$diff = time() - $ctime;
var_dump("[".$region."] - After shared api first init hook : " . $diff . " sec");
});
App::init()
@ -363,7 +368,8 @@ App::init()
->inject('dbForProject')
->inject('mode')
->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Usage $queueForUsage, Database $dbForProject, string $mode) use ($databaseListener) {
$ctime = time();
var_dump("[".$region."] - Before shared api second init hook");
$route = $utopia->getRoute();
if (
@ -521,6 +527,8 @@ App::init()
;
}
}
$diff = time() - $ctime;
var_dump("[".$region."] - After shared api first init hook : " . $diff . " sec");
});
App::init()
@ -551,6 +559,10 @@ App::shutdown()
->inject('project')
->inject('dbForProject')
->action(function (App $utopia, Request $request, Response $response, Document $project, Database $dbForProject) {
$ctime = time();
var_dump("[".$region."] - Before shared api first shutdown hook");
$route = $utopia->getRoute();
$sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS_DEFAULT;
$session = $response->getPayload();
$userId = $session['userId'] ?? '';
@ -575,6 +587,8 @@ App::shutdown()
}
$dbForProject->purgeCachedDocument('users', $userId);
$diff = time() - $ctime;
var_dump("[".$region."] - After shared api first shutdown hook : " . $diff . " sec");
});
App::shutdown()
@ -597,6 +611,10 @@ App::shutdown()
->inject('dbForConsole')
->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole) use ($parseLabel) {
$ctime = time();
var_dump("[".$region."] - Before shared api second shutdown hook");
$route = $utopia->getRoute();
$responsePayload = $response->getPayload();
if (!empty($queueForEvents->getEvent())) {
@ -798,6 +816,8 @@ App::shutdown()
}
}
}
$diff = time() - $ctime;
var_dump("[".$region."] - After shared api second shutdown hook : " . $diff . " sec");
});
App::init()