-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deleted functions #4691
Deleted functions #4691
Conversation
schedules clean up
schedules clean up
schedules clean up
app/config/variables.php
Outdated
], | ||
[ | ||
'name' => '_APP_MAINTENANCE_RETENTION_SCHEDULES', | ||
'description' => 'Deleted functions schedule cleanup interval (in seconds) ', | ||
'introduction' => '1.2.0', | ||
'default' => '86400', | ||
'required' => false, | ||
'question' => '', | ||
'filter' => '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a formatting thing. Lets add this variable near the other maintenance variables
app/workers/deletes.php
Outdated
$sum = $limit = 50; | ||
$offset = 0; | ||
/** @var Document[] $functions */ | ||
while ($sum >= $limit) { | ||
$schedules = $this->getConsoleDB()->find('schedules', [ | ||
Query::equal('region', [App::getEnv('_APP_REGION', 'default')]), | ||
Query::equal('resourceType', ['function']), | ||
Query::lessThanEqual('resourceUpdatedAt', $datetime), | ||
Query::equal('active', [false]), | ||
Query::limit($limit), | ||
Query::offset($offset), | ||
]); | ||
|
||
$sum = \count($schedules); | ||
$offset = $offset + $limit; | ||
|
||
foreach ($schedules as $schedule) { | ||
Console::info('Querying schedule for function ' . $schedule->getAttribute('resourceId')); | ||
$project = $this->getConsoleDB()->getDocument('projects', $schedule->getAttribute('projectId')); | ||
|
||
if ($project->isEmpty()) { | ||
Console::success('Deleting schedule for function ' . $schedule->getAttribute('resourceId')); | ||
continue; | ||
} | ||
|
||
$function = $this->getProjectDB($project)->getDocument('functions', $schedule->getAttribute('resourceId')); | ||
|
||
if ($function->isEmpty()) { | ||
$this->getConsoleDB()->deleteDocument('schedules', $schedule->getId()); | ||
Console::success('Deleting schedule for function ' . $schedule->getAttribute('resourceId')); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a function called deleteByGroup
which we can reuse. We don't need to do write the pagination logic again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the comments
schedules clean up
Co-authored-by: Christy Jacob <christyjacob4@gmail.com>
schedules clean up
…eat-schedules-deletions
schedules clean up
schedules clean up
…eat-schedules-deletions # Conflicts: # app/config/variables.php
…eat-schedules-deletions
Co-authored-by: Christy Jacob <christyjacob4@gmail.com>
Co-authored-by: Christy Jacob <christyjacob4@gmail.com>
…eat-schedules-deletions
schedules clean up
Deleted function schedules clean up