mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
feat: use static array for console db
This commit is contained in:
parent
651c826de1
commit
56aa30fd52
2 changed files with 12 additions and 7 deletions
|
|
@ -618,10 +618,6 @@ class DeletesV1 extends Worker
|
|||
|
||||
$executionStart = \microtime(true);
|
||||
|
||||
var_dump("Collection : $collection");
|
||||
var_dump("Database : {$database->getDefaultDatabase()}");
|
||||
var_dump("Namespace : {$database->getNamespace()}");
|
||||
|
||||
while ($sum === $limit) {
|
||||
$chunk++;
|
||||
|
||||
|
|
@ -629,7 +625,7 @@ class DeletesV1 extends Worker
|
|||
|
||||
$sum = count($results);
|
||||
|
||||
Console::info('Deleting chunk #' . $chunk . '. Found ' . $sum . ' documents');
|
||||
Console::info('Deleting chunk #' . $chunk . '. Found ' . $sum . ' documents in collection ' . '_' . $database->getNamespace() . '_' . $collection);
|
||||
|
||||
foreach ($results as $document) {
|
||||
$this->deleteById($document, $database, $callback);
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ abstract class Worker
|
|||
* @return Database
|
||||
*/
|
||||
protected static $databases = []; // TODO: @Meldiron This should probably be responsibility of utopia-php/pools
|
||||
|
||||
protected function getProjectDB(Document $project): Database
|
||||
{
|
||||
global $register;
|
||||
|
|
@ -186,8 +187,6 @@ abstract class Worker
|
|||
|
||||
$databaseName = $project->getAttribute('database');
|
||||
|
||||
var_dump(array_keys(self::$databases));
|
||||
|
||||
if (isset(self::$databases[$databaseName])) {
|
||||
$database = self::$databases[$databaseName];
|
||||
$database->setNamespace('_' . $project->getInternalId());
|
||||
|
|
@ -219,6 +218,14 @@ abstract class Worker
|
|||
|
||||
$pools = $register->get('pools'); /** @var \Utopia\Pools\Group $pools */
|
||||
|
||||
$databaseName = 'console';
|
||||
|
||||
if (isset(self::$databases[$databaseName])) {
|
||||
$database = self::$databases[$databaseName];
|
||||
$database->setNamespace('console');
|
||||
return $database;
|
||||
}
|
||||
|
||||
$dbAdapter = $pools
|
||||
->get('console')
|
||||
->pop()
|
||||
|
|
@ -227,6 +234,8 @@ abstract class Worker
|
|||
|
||||
$database = new Database($dbAdapter, $this->getCache());
|
||||
|
||||
self::$databases[$databaseName] = $database;
|
||||
|
||||
$database->setNamespace('console');
|
||||
|
||||
return $database;
|
||||
|
|
|
|||
Loading…
Reference in a new issue