chore: format

This commit is contained in:
Binyamin Yawitz
2024-09-03 19:32:30 -04:00
parent 686b5439a2
commit cedf3cf28d
10 changed files with 32 additions and 39 deletions
+14 -14
View File
@@ -175,23 +175,23 @@ abstract class Migration
Console::log('Migrating Collection ' . $collection['$id'] . ':');
foreach ($this->documentsIterator($collection['$id']) as $document) {
if (empty($document->getId()) || empty($document->getCollection())) {
return;
}
if (empty($document->getId()) || empty($document->getCollection())) {
return;
}
$old = $document->getArrayCopy();
$new = call_user_func($callback, $document);
$old = $document->getArrayCopy();
$new = call_user_func($callback, $document);
if (is_null($new) || $new->getArrayCopy() == $old) {
return;
}
if (is_null($new) || $new->getArrayCopy() == $old) {
return;
}
try {
$this->projectDB->updateDocument($document->getCollection(), $document->getId(), $document);
} catch (\Throwable $th) {
Console::error('Failed to update document: ' . $th->getMessage());
return;
}
try {
$this->projectDB->updateDocument($document->getCollection(), $document->getId(), $document);
} catch (\Throwable $th) {
Console::error('Failed to update document: ' . $th->getMessage());
return;
}
}
}
}
+12 -4
View File
@@ -5,7 +5,6 @@ namespace Appwrite\Platform\Tasks;
use Appwrite\Migration\Migration;
use Redis;
use Utopia\App;
use Utopia\Cache\Cache;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -38,8 +37,8 @@ class Migrate extends Action
->inject('authorization')
->inject('console')
->callback(function ($version, $dbForConsole, $getProjectDB, Registry $register, Authorization $authorization, Document $console) {
\Co\run(function () use ($version, $dbForConsole, $getProjectDB, $register, Authorization $authorization, Document $console) {
$this->action($version, $dbForConsole, $getProjectDB, $register, Authorization $authorization, Document $console);
\Co\run(function () use ($version, $dbForConsole, $getProjectDB, $register, $authorization, $console) {
$this->action($version, $dbForConsole, $getProjectDB, $register, $authorization, $console);
});
});
}
@@ -47,7 +46,16 @@ class Migrate extends Action
private function clearProjectsCache(Document $project)
{
try {
$cache->purge("cache-_{$project->getInternalId()}:*");
$iterator = null;
do {
$pattern = "default-cache-_{$project->getInternalId()}:*";
$keys = $this->redis->scan($iterator, $pattern, 1000);
if ($keys !== false) {
foreach ($keys as $key) {
$this->redis->del($key);
}
}
} while ($iterator > 0);
} catch (\Throwable $th) {
Console::error('Failed to clear project ("' . $project->getId() . '") cache with error: ' . $th->getMessage());
}
+1 -1
View File
@@ -6,10 +6,10 @@ use Appwrite\Utopia\Fetch\BodyMultipart;
use Appwrite\Utopia\Response\Filter;
use Exception;
use JsonException;
use Swoole\Http\Response as SwooleHTTPResponse;
// Keep last
use Utopia\Database\Document;
use Utopia\Swoole\Response as SwooleResponse;
// Keep last
/**
+1 -7
View File
@@ -2,9 +2,6 @@
namespace Appwrite\Utopia\Response;
use Appwrite\Utopia\Fetch\BodyMultipart;
use Appwrite\Utopia\Response\Filter;
use Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response\Model\Account;
use Appwrite\Utopia\Response\Model\AlgoArgon2;
use Appwrite\Utopia\Response\Model\AlgoBcrypt;
@@ -109,11 +106,8 @@ use Appwrite\Utopia\Response\Model\Variable;
use Appwrite\Utopia\Response\Model\VcsContent;
use Appwrite\Utopia\Response\Model\Webhook;
use Exception;
use JsonException;
use Swoole\Http\Response as SwooleHTTPResponse;
// Keep last
use Utopia\Database\Document;
use Utopia\Swoole\Response as SwooleResponse;
class Models
{