delete unnecessary project collections task
This commit is contained in:
parent
f5e9094bdc
commit
ce596b2f2b
1 changed files with 10 additions and 6 deletions
|
@ -9,7 +9,7 @@ use Utopia\CLI\Console;
|
||||||
use Utopia\Database\Database;
|
use Utopia\Database\Database;
|
||||||
use Utopia\Database\Query;
|
use Utopia\Database\Query;
|
||||||
use Utopia\Pools\Group;
|
use Utopia\Pools\Group;
|
||||||
use Utopia\Registry\Registry;
|
use Utopia\Validator\Numeric;
|
||||||
|
|
||||||
class PatchDeleteProjectCollections extends Action
|
class PatchDeleteProjectCollections extends Action
|
||||||
{
|
{
|
||||||
|
@ -34,16 +34,16 @@ class PatchDeleteProjectCollections extends Action
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->desc('Delete unnecessary project collections')
|
->desc('Delete unnecessary project collections')
|
||||||
|
->param('pos', 0, new Numeric(), 'Resume deletion from param pos', true)
|
||||||
->inject('pools')
|
->inject('pools')
|
||||||
->inject('cache')
|
->inject('cache')
|
||||||
->inject('dbForConsole')
|
->inject('dbForConsole')
|
||||||
->inject('register')
|
->callback(function (int $pos, Group $pools, Cache $cache, Database $dbForConsole) {
|
||||||
->callback(function (Group $pools, Cache $cache, Database $dbForConsole, Registry $register) {
|
$this->action($pos, $pools, $cache, $dbForConsole);
|
||||||
$this->action($pools, $cache, $dbForConsole, $register);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action(Group $pools, Cache $cache, Database $dbForConsole, Registry $register): void
|
public function action(int $pos, Group $pools, Cache $cache, Database $dbForConsole): void
|
||||||
{
|
{
|
||||||
//docker compose exec -t appwrite patch-delete-project-collections
|
//docker compose exec -t appwrite patch-delete-project-collections
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class PatchDeleteProjectCollections extends Action
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$limit = 50;
|
$limit = 50;
|
||||||
$sum = 50;
|
$sum = 50;
|
||||||
$offset = 0;
|
$offset = $pos;
|
||||||
while (!empty($projects)) {
|
while (!empty($projects)) {
|
||||||
foreach ($projects as $project) {
|
foreach ($projects as $project) {
|
||||||
|
|
||||||
|
@ -114,6 +114,10 @@ class PatchDeleteProjectCollections extends Action
|
||||||
Query::offset($offset),
|
Query::offset($offset),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (!empty($projects)) {
|
||||||
|
Console::log('Querying..... offset=' . $offset . ' , limit=' . $limit . ', count=' . $count);
|
||||||
|
}
|
||||||
|
|
||||||
$offset = $offset + $limit;
|
$offset = $offset + $limit;
|
||||||
$count = $count + $sum;
|
$count = $count + $sum;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue