Export a method from Workflow::Activity for timeouts and use it in all current Workflows

This commit is contained in:
Colin Kuskie 2008-08-30 20:34:52 +00:00
parent 85ecaa9a09
commit 726bd5ee05
12 changed files with 36 additions and 12 deletions

View file

@ -81,13 +81,14 @@ sub execute {
my $start = time();
my $log = $self->session->errorHandler;
$log->info('Searching for EMS items that have been in the cart too long.');
my $ttl = $self->getTTL;
my $items = $self->session->db->read("select itemId, cartId, assetId from cartItem where
assetId in (select assetId from asset where className like 'WebGUI::Asset::Sku::EMS%')
and DATE_ADD(dateAdded, interval ".($self->get("expireAfter") + 0)." second) < now()");
while (my ($itemId, $cartId, $assetId) = $items->array) {
$log->info('Removing item '.$itemId.' (asset '.$assetId.') from cart '.$cartId);
WebGUI::Shop::Cart->new($self->session, $cartId)->getItem($itemId)->remove;
if (time() - $start > 55) {
if (time() - $start > $ttl) {
$items->finish;
$log->('Ran out of time. Will have to expire the rest later.');
return $self->WAITING;