a little better handling of scratch variables

This commit is contained in:
JT Smith 2008-11-12 21:17:53 +00:00
parent 07519c7e98
commit 2a7ffdc7fe

View file

@ -81,10 +81,17 @@ sub execute {
my $time = time(); my $time = time();
my $ttl = $self->getTTL; my $ttl = $self->getTTL;
my $assets = JSON->new->decode($instance->getScratch("syndicatedassets") || '[]'); # get asset list
if (scalar @$assets < 1) { my $scratch = $instance->getScratch("syndicatedassets");
$assets = $self->session->db->buildArrayRef("select assetId from asset where className like 'WebGUI::Asset::Wobject::SyndicatedContent'"); my $assets = [];
} if ($scratch) {
$assets = JSON->new->decode($scratch);
}
else {
$assets = $self->session->db->buildArrayRef("select assetId from asset where className like 'WebGUI::Asset::Wobject::SyndicatedContent'");
}
# process each syndicated content asset
while (my $id = shift(@{$assets})) { while (my $id = shift(@{$assets})) {
# Get RSS data, which will be stored in the cache # Get RSS data, which will be stored in the cache
$log->info("GetSyndicatedContent: Caching for $id"); $log->info("GetSyndicatedContent: Caching for $id");
@ -107,6 +114,8 @@ sub execute {
$instance->setScratch("syndicatedassets", JSON->new->encode($assets)); $instance->setScratch("syndicatedassets", JSON->new->encode($assets));
return $self->WAITING; return $self->WAITING;
} }
# if we've completed the list, clean up
$instance->deleteScratch("syndicatedassets"); $instance->deleteScratch("syndicatedassets");
return $self->COMPLETE; return $self->COMPLETE;
} }