added automatic purging of old asset revisions

This commit is contained in:
JT Smith 2005-07-07 23:33:21 +00:00
parent e7d282c730
commit eb3115d3f9
7 changed files with 125 additions and 24 deletions

View file

@ -13,7 +13,6 @@ package Hourly::DeleteExpiredClipboard;
use strict;
use WebGUI::Asset;
use WebGUI::DateTime;
use WebGUI::Session;
use WebGUI::SQL;
@ -21,9 +20,9 @@ use WebGUI::SQL;
sub process {
if ($session{config}{DeleteExpiredClipboard_offset} ne "") {
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredClipboard_offset}));
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='clipboard' and lastUpdated <".$expireDate);
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='clipboard' and stateChanged <".$expireDate);
while (my ($id, $class) = $sth->array) {
my $asset = WebGUI::Asset->newByDynamicClass($id,$class);
my $asset = WebGUI::Asset->new($id,$class);
$asset->trash;
}
$sth->finish;

View file

@ -0,0 +1,35 @@
package Hourly::DeleteExpiredRevisions;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2005 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use WebGUI::Asset;
use WebGUI::Session;
use WebGUI::SQL;
#-----------------------------------------
sub process {
if ($session{config}{DeleteExpiredRevisions_offset} ne "") {
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredRevisions_offset}));
my $sth = WebGUI::SQL->read("select assetData.assetId,asset.className,assetData.revisionDate from asset left join assetData on asset.assetId=assetData.assetId where assetData.revisionDate<".$expireDate." order by assetData.revisionDate asc");
while (my ($id, $class, $version) = $sth->array) {
my $asset = WebGUI::Asset->new($id,$class,$version);
if ($asset->getRevisionCount("approved") > 1) {
$asset->purgeRevision;
}
}
$sth->finish;
}
}
1;

View file

@ -13,7 +13,6 @@ package Hourly::DeleteExpiredTrash;
use strict;
use WebGUI::Asset;
use WebGUI::DateTime;
use WebGUI::Session;
use WebGUI::SQL;
@ -21,9 +20,9 @@ use WebGUI::SQL;
sub process {
if ($session{config}{DeleteExpiredTrash_offset} ne "") {
my $expireDate = (time()-(86400*$session{config}{DeleteExpiredTrash_offset}));
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='trash' and lastUpdated <".$expireDate);
my $sth = WebGUI::SQL->read("select assetId,className from asset where state='trash' and stateChanged <".$expireDate);
while (my ($id, $class) = $sth->array) {
my $asset = WebGUI::Asset->newByDynamicClass($id,$class);
my $asset = WebGUI::Asset->new($id,$class);
$asset->purge;
}
$sth->finish;

View file

@ -21,9 +21,10 @@ sub process {
my $offset = $session{config}{TrashExpiredContent_offset};
if ($offset ne "") {
my $epoch = time()-(86400*$offset);
my $sth = WebGUI::SQL->read("select assetId,className from asset where endDate<".$epoch);
while (my ($assetId, $class) = $sth->array) {
my $asset = WebGUI::Asset->newByDynamicClass($assetId,$class);
my $sth = WebGUI::SQL->read("select asset.assetId,asset.className,max(assetData.revisionDate) from asset left join assetData on
asset.assetId=assetData.assetId where assetData.endDate<".$epoch." and assetData.status<>'pending' group by asset.assetData");
while (my ($assetId, $class, $version) = $sth->array) {
my $asset = WebGUI::Asset->new($assetId,$class,$version);
$asset->trash;
}
$sth->finish;