mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge branch '1.6.x' of github.com:appwrite/appwrite into multi-region-support
This commit is contained in:
commit
68e8b7ca2b
1 changed files with 4 additions and 29 deletions
|
|
@ -47,13 +47,15 @@ class Maintenance extends Action
|
||||||
|
|
||||||
Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds");
|
Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds");
|
||||||
|
|
||||||
$this->foreachProject($dbForPlatform, function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) {
|
$dbForPlatform->foreach('projects', function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) {
|
||||||
$queueForDeletes
|
$queueForDeletes
|
||||||
->setType(DELETE_TYPE_MAINTENANCE)
|
->setType(DELETE_TYPE_MAINTENANCE)
|
||||||
->setProject($project)
|
->setProject($project)
|
||||||
->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly))
|
->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly))
|
||||||
->trigger();
|
->trigger();
|
||||||
});
|
}, [
|
||||||
|
Query::limit(100),
|
||||||
|
]);
|
||||||
|
|
||||||
$queueForDeletes
|
$queueForDeletes
|
||||||
->setType(DELETE_TYPE_MAINTENANCE)
|
->setType(DELETE_TYPE_MAINTENANCE)
|
||||||
|
|
@ -68,33 +70,6 @@ class Maintenance extends Action
|
||||||
}, $interval, $delay);
|
}, $interval, $delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function foreachProject(Database $dbForPlatform, callable $callback): void
|
|
||||||
{
|
|
||||||
// TODO: @Meldiron name of this method no longer matches. It does not delete, and it gives whole document
|
|
||||||
$count = 0;
|
|
||||||
$chunk = 0;
|
|
||||||
$limit = 50;
|
|
||||||
$sum = $limit;
|
|
||||||
$executionStart = \microtime(true);
|
|
||||||
|
|
||||||
while ($sum === $limit) {
|
|
||||||
$projects = $dbForPlatform->find('projects', [Query::limit($limit), Query::offset($chunk * $limit)]);
|
|
||||||
|
|
||||||
$chunk++;
|
|
||||||
|
|
||||||
/** @var string[] $projectIds */
|
|
||||||
$sum = count($projects);
|
|
||||||
|
|
||||||
foreach ($projects as $project) {
|
|
||||||
$callback($project);
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$executionEnd = \microtime(true);
|
|
||||||
Console::info("Found {$count} projects " . ($executionEnd - $executionStart) . " seconds");
|
|
||||||
}
|
|
||||||
|
|
||||||
private function notifyDeleteConnections(Delete $queueForDeletes): void
|
private function notifyDeleteConnections(Delete $queueForDeletes): void
|
||||||
{
|
{
|
||||||
$queueForDeletes
|
$queueForDeletes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue