Merge commit '17ce3572bf' into WebGUI8. All tests passing.
This commit is contained in:
commit
5e502fee53
117 changed files with 2012 additions and 1027 deletions
|
|
@ -17,7 +17,7 @@ package WebGUI::Workflow::Activity::PurgeOldInboxMessages;
|
|||
|
||||
use strict;
|
||||
use base 'WebGUI::Workflow::Activity';
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Inbox::Message;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -77,45 +77,32 @@ See WebGUI::Workflow::Activity::execute() for details.
|
|||
=cut
|
||||
|
||||
sub execute {
|
||||
my ($self, $nothing, $instance) = @_;
|
||||
my ($self, undef, $instance) = @_;
|
||||
my $session = $self->session;
|
||||
my $log = $session->errorHandler;
|
||||
|
||||
# keep track of how much time it's taking
|
||||
my $start = time;
|
||||
my $limit = 2_500;
|
||||
my $endTime = time() + $self->getTTL;;
|
||||
|
||||
my $sth
|
||||
= $session->db->read(
|
||||
"SELECT messageId FROM inbox WHERE completedOn IS NOT NULL AND dateStamp < ?",
|
||||
[ $start - $self->get('purgeAfter') ],
|
||||
);
|
||||
|
||||
while ( ( my $messageId ) = $sth->array ) {
|
||||
$session->db->write(
|
||||
"DELETE FROM inbox WHERE messageId = ?",
|
||||
[ $messageId ],
|
||||
[ time() - $self->get('purgeAfter') ],
|
||||
);
|
||||
|
||||
MESSAGE: while ( ( my $messageId ) = $sth->array ) {
|
||||
# give up if we're taking too long
|
||||
if (time - $start > 120) {
|
||||
if (time() > $endTime) {
|
||||
$sth->finish;
|
||||
return $self->WAITING(1);
|
||||
}
|
||||
}
|
||||
|
||||
my $message = WebGUI::Inbox::Message->new($session, $messageId);
|
||||
next MESSAGE unless $message;
|
||||
$message->purge;
|
||||
}
|
||||
|
||||
# If there are more messages waiting to be purged, return WAITING
|
||||
if ( $sth->rows >= $limit ) {
|
||||
return $self->WAITING(1);
|
||||
}
|
||||
else {
|
||||
return $self->COMPLETE;
|
||||
}
|
||||
$sth->finish;
|
||||
return $self->COMPLETE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -75,12 +75,14 @@ See WebGUI::Workflow::Activity::execute() for details.
|
|||
=cut
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $sth = $self->session->db->read( "select assetId from Event where endDate < ?", [ time() - $self->get("trashAfter") ]);
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $finishTime = time() + $self->getTTL;
|
||||
my $date = WebGUI::DateTime->new($session, time() - $self->get("trashAfter") );
|
||||
my $sth = $session->db->read( "select Event.assetId, revisionDate from Event join assetData using (assetId, revisionDate) where endDate < ? and revisionDate = (select max(revisionDate) from assetData where assetData.assetId=Event.assetId);", [ $date->toDatabaseDate ]);
|
||||
EVENT: while ( my ($id) = $sth->array ) {
|
||||
my $asset = eval { WebGUI::Asset::Event->newById($self->session, $id); };
|
||||
if (! Exception::Class->caught() && $asset->eventEndDate < time() - $self->trashAfter) {
|
||||
my $asset = eval { WebGUI::Asset->newById($session, $id); };
|
||||
if (! Exception::Class->caught()) {
|
||||
$asset->trash;
|
||||
}
|
||||
last EVENT if time() > $finishTime;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue