Fix the delete expired events workflow (again). Fixes bug #11619

This commit is contained in:
Colin Kuskie 2010-06-09 11:28:00 -07:00
parent 908b9724a1
commit 6d2d950f52
3 changed files with 109 additions and 3 deletions

View file

@ -75,11 +75,13 @@ 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 = WebGUI::Asset::Event->new( $self->session, $id );
my $asset = WebGUI::Asset::Event->new( $session, $id );
if ( defined $asset ) {
$asset->trash;
}