feat: update worker class
This commit is contained in:
parent
3ab4dcb7c1
commit
a0c43f1fe3
2 changed files with 13 additions and 13 deletions
|
@ -324,16 +324,17 @@ $cli
|
||||||
foreach ($points as $point) {
|
foreach ($points as $point) {
|
||||||
$projectId = $point['projectId'];
|
$projectId = $point['projectId'];
|
||||||
|
|
||||||
/** Get the Dabatase name from the console DB */
|
|
||||||
$project = Authorization::skip(fn() => $dbForConsole->getDocument('projects', $projectId));
|
|
||||||
$dbName = $project->getAttribute('database', '');
|
|
||||||
$projectDB = $dbPool->get($dbName);
|
|
||||||
|
|
||||||
$dbForProject = new Database(new MariaDB($projectDB), $cacheAdapter);
|
|
||||||
$dbForProject->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
|
|
||||||
|
|
||||||
|
|
||||||
if (!empty($projectId) && $projectId !== 'console') {
|
if (!empty($projectId) && $projectId !== 'console') {
|
||||||
|
/** Get the Dabatase name from the console DB */
|
||||||
|
$project = Authorization::skip(fn() => $dbForConsole->getDocument('projects', $projectId));
|
||||||
|
var_dump($projectId);
|
||||||
|
var_dump($project);
|
||||||
|
$dbName = $project->getAttribute('database', '');
|
||||||
|
$projectDB = $dbPool->getDB($dbName);
|
||||||
|
|
||||||
|
$dbForProject = new Database(new MariaDB($projectDB), $cacheAdapter);
|
||||||
|
$dbForProject->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
|
||||||
|
|
||||||
$dbForProject->setNamespace('_' . $projectId);
|
$dbForProject->setNamespace('_' . $projectId);
|
||||||
$metricUpdated = $metric;
|
$metricUpdated = $metric;
|
||||||
|
|
||||||
|
@ -373,8 +374,6 @@ $cli
|
||||||
Console::warning($e->getTraceAsString());
|
Console::warning($e->getTraceAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbPool->put($projectDB, $dbName);
|
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Console::warning("Failed to Query: {$e->getMessage()}");
|
Console::warning("Failed to Query: {$e->getMessage()}");
|
||||||
|
|
|
@ -160,19 +160,20 @@ abstract class Worker
|
||||||
*/
|
*/
|
||||||
protected function getProjectDB(string $projectId): Database
|
protected function getProjectDB(string $projectId): Database
|
||||||
{
|
{
|
||||||
|
global $register;
|
||||||
|
|
||||||
if (!$projectId) {
|
if (!$projectId) {
|
||||||
throw new \Exception('ProjectID not provided - cannot get database');
|
throw new \Exception('ProjectID not provided - cannot get database');
|
||||||
}
|
}
|
||||||
|
|
||||||
$namespace = "_{$projectId}";
|
$namespace = "_{$projectId}";
|
||||||
|
|
||||||
global $register;
|
|
||||||
$dbForConsole = $this->getConsoleDB();
|
$dbForConsole = $this->getConsoleDB();
|
||||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||||
$dbName = $project->getAttribute('database', '');
|
$dbName = $project->getAttribute('database', '');
|
||||||
|
|
||||||
$projectDB = $register->get('dbPool')->getDB($dbName);
|
$projectDB = $register->get('dbPool')->getDB($dbName);
|
||||||
|
|
||||||
|
|
||||||
return $this->getDB(self::DATABASE_PROJECT, $projectDB, $namespace);
|
return $this->getDB(self::DATABASE_PROJECT, $projectDB, $namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue