1
0
Fork 0
mirror of synced 2024-10-03 19:53:33 +13:00

add reclaim logic

This commit is contained in:
Matej Bačo 2023-03-22 20:35:04 +01:00
parent b558a284f3
commit 567cb01b99

View file

@ -7,6 +7,7 @@ use Utopia\CLI\Console;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Pools\Group;
class PatchDeleteScheduleUpdatedAtAttribute extends Action class PatchDeleteScheduleUpdatedAtAttribute extends Action
{ {
@ -19,15 +20,16 @@ class PatchDeleteScheduleUpdatedAtAttribute extends Action
{ {
$this $this
->desc('Ensure function collections do not have scheduleUpdatedAt attribute') ->desc('Ensure function collections do not have scheduleUpdatedAt attribute')
->inject('pools')
->inject('dbForConsole') ->inject('dbForConsole')
->inject('getProjectDB') ->inject('getProjectDB')
->callback(fn (Database $dbForConsole, callable $getProjectDB) => $this->action($dbForConsole, $getProjectDB)); ->callback(fn (Group $pools, Database $dbForConsole, callable $getProjectDB) => $this->action($pools, $dbForConsole, $getProjectDB));
} }
/** /**
* Iterate over every function on every project to make sure there is a schedule. If not, recreate the schedule. * Iterate over every function on every project to make sure there is a schedule. If not, recreate the schedule.
*/ */
public function action(Database $dbForConsole, callable $getProjectDB): void public function action(Group $pools, Database $dbForConsole, callable $getProjectDB): void
{ {
Authorization::disable(); Authorization::disable();
Authorization::setDefaultStatus(false); Authorization::setDefaultStatus(false);
@ -62,6 +64,8 @@ class PatchDeleteScheduleUpdatedAtAttribute extends Action
} catch (\Throwable $th) { } catch (\Throwable $th) {
Console::warning("'scheduleUpdatedAt' errored: {$th->getMessage()}"); Console::warning("'scheduleUpdatedAt' errored: {$th->getMessage()}");
} }
$pools->reclaim();
} }
$projectCursor = $projects[array_key_last($projects)]; $projectCursor = $projects[array_key_last($projects)];