converted delete expired groupings hourly script

This commit is contained in:
JT Smith 2006-03-01 22:02:52 +00:00
parent 136a89ee7a
commit 741de69841
4 changed files with 103 additions and 38 deletions

View file

@ -1,37 +0,0 @@
package Hourly::DeleteExpiredGroupings;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2006 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::DateTime;
use WebGUI::Session;
use WebGUI::SQL;
#-----------------------------------------
sub process {
my @date = WebGUI::DateTime::localtime();
if ($date[3] == 3) { # only occurs at 3am on the day in question.
my $sth = WebGUI::SQL->read("select groupId,deleteOffset,dbCacheTimeout from groups");
while (my $data = $sth->hashRef) {
if ($data->{dbCacheTimeout} > 0) {
# there is no need to wait deleteOffset days for expired external group cache data
WebGUI::SQL->write("delete from groupings where groupId=".quote($data->{groupId})." and expireDate < ".WebGUI::DateTime::time());
} else {
WebGUI::SQL->write("delete from groupings where groupId=".quote($data->{groupId})." and expireDate < "
.(WebGUI::DateTime::time()-(86400*$data->{deleteOffset})));
}
}
$sth->finish;
}
}
1;