migrate to getLineageIterator to save memory
This commit is contained in:
parent
cc87552a22
commit
2c75ab27e6
34 changed files with 794 additions and 187 deletions
|
|
@ -77,21 +77,30 @@ sub execute {
|
|||
ARCHIVE: while (my $archive = $getAnArchive->()) {
|
||||
next ARCHIVE unless $archive && $archive->get("archiveAfter");
|
||||
my $archiveDate = $epoch - $archive->get("archiveAfter");
|
||||
my $folders = $archive->getLineage(
|
||||
my $folderIter = $archive->getLineageIterator(
|
||||
['children'],
|
||||
{
|
||||
statusToInclude => ['approved'],
|
||||
whereClause => 'creationDate < '.$session->db->quote($archiveDate),
|
||||
returnObjects => 1,
|
||||
},
|
||||
);
|
||||
FOLDER: foreach my $folder (@{ $folders }) {
|
||||
next FOLDER unless $folder;
|
||||
my $stories = $folder->getLineage(
|
||||
['children'], { returnObjects => 1, },
|
||||
);
|
||||
STORY: foreach my $story (@{ $stories }) {
|
||||
next STORY unless $story;
|
||||
FOLDER: while ( 1 ) {
|
||||
my $folder;
|
||||
eval { $folder = $folderIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $folder;
|
||||
my $storyIter = $folder->getLineageIterator( ['children'] );
|
||||
STORY: while ( 1 ) {
|
||||
my $story;
|
||||
eval { $story = $storyIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $story;
|
||||
$story->update({ status => 'archived' });
|
||||
if (time() > $expireTime) {
|
||||
return $self->WAITING(1);
|
||||
|
|
|
|||
|
|
@ -107,14 +107,20 @@ sub execute {
|
|||
|
||||
# kill temporary assets
|
||||
my $tempspace = WebGUI::Asset->getTempspace($self->session);
|
||||
my $children = $tempspace->getLineage(["children"], {
|
||||
returnObjects => 1,
|
||||
my $childIter = $tempspace->getLineageIterator(["children"], {
|
||||
statesToInclude => [qw(trash clipboard published)],
|
||||
statusToInclude => [qw(pending archived approved)],
|
||||
});
|
||||
foreach my $asset (@{$children}) {
|
||||
if (time() - $asset->get("revisionDate") > $self->get("storageTimeout")) {
|
||||
unless ($asset->purge) {
|
||||
while ( 1 ) {
|
||||
my $child;
|
||||
eval { $child = $childIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $child;
|
||||
if (time() - $child->get("revisionDate") > $self->get("storageTimeout")) {
|
||||
unless ($child->purge) {
|
||||
return $self->ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,11 +78,18 @@ sub execute {
|
|||
my $limit = 2_500;
|
||||
my $timeLimit = $self->getTTL;
|
||||
|
||||
my $list = $root->getLineage( ['descendants'], { returnObjects => 1,
|
||||
my $emsFormIter = $root->getLineageIterator( ['descendants'], {
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
|
||||
for my $emsForm ( @$list ) {
|
||||
while ( 1 ) {
|
||||
my $emsForm;
|
||||
eval { $emsForm = $emsFormIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $emsForm;
|
||||
my $daysBeforeCleanup = $emsForm->get('daysBeforeCleanup') ;
|
||||
next if ! $daysBeforeCleanup;
|
||||
my $whereClause = q{ submissionStatus='denied' };
|
||||
|
|
@ -91,12 +98,19 @@ sub execute {
|
|||
}
|
||||
my $checkDate = time - ( 60*60*24* $daysBeforeCleanup );
|
||||
$whereClause .= q{ and assetData.lastModified < } . $checkDate;
|
||||
my $res = $emsForm->getLineage(['children'],{ returnObjects => 1,
|
||||
my $submissionIter = $emsForm->getLineageIterator(['children'],{
|
||||
joinClass => 'WebGUI::Asset::EMSSubmission',
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||
whereClause => $whereClause,
|
||||
} );
|
||||
for my $submission ( @$res ) {
|
||||
while ( 1 ) {
|
||||
my $submission;
|
||||
eval { $submission = $submissionIter->() };
|
||||
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
|
||||
$session->log->error($x->full_message);
|
||||
next;
|
||||
}
|
||||
last unless $submission;
|
||||
$submission->purge;
|
||||
$limit--;
|
||||
return $self->WAITING(1) if ! $limit or time > $start + $timeLimit;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ sub execute {
|
|||
my $limit = 2_500;
|
||||
my $timeLimit = 60;
|
||||
|
||||
my $list = $root->getLineage( ['descendants'], { returnObjects => 1,
|
||||
my $list = $root->getLineage( ['descendants'], {
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue