merging 6.7.8 changes and bug fixes
This commit is contained in:
parent
4bd429bcac
commit
fdfb9bf5ae
8 changed files with 95 additions and 58 deletions
|
|
@ -13,6 +13,7 @@ package Hourly::ArchiveOldPosts;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset::Post;
|
||||
use WebGUI::Asset::Wobject::Collaboration;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
|
@ -20,15 +21,18 @@ use WebGUI::SQL;
|
|||
#-----------------------------------------
|
||||
sub process {
|
||||
my $epoch = WebGUI::DateTime::time();
|
||||
my $a = WebGUI::SQL->read("select asset.lineage,Collaboration.archiveAfter from Collaboration left join asset on Collaboration.assetId=asset.assetId");
|
||||
while (my ($lineage, $archiveAfter) = $a->array) {
|
||||
my $archiveDate = $epoch - $archiveAfter;
|
||||
my $sql = "select asset.assetId,asset.className, max(assetData.revisionDate) from Post left join asset on Post.assetId=asset.assetId
|
||||
left join assetData on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
|
||||
where Post.dateUpdated<$archiveDate and assetData.status='approved' and asset.lineage like ".quote($lineage."%")." group by asset.assetId";
|
||||
my $a = WebGUI::SQL->read("select assetId from asset where className='WebGUI::Asset::Wobject::Collaboration'");
|
||||
while (my ($assetId) = $a->array) {
|
||||
my $cs = WebGUI::Asset::Wobject::Collaboration->new($assetId);
|
||||
my $archiveDate = $epoch - $cs->get("archiveAfter");
|
||||
my $sql = "select asset.assetId, assetData.revisionDate from Post left join asset on asset.assetId=Post.assetId
|
||||
left join assetData on Post.assetId=assetData.assetId and Post.revisionDate=assetData.revisionDate
|
||||
where Post.dateUpdated<$archiveDate and assetData.status='approved' and asset.state='published'
|
||||
and asset.lineage like ".quote($cs->get("lineage").'%');
|
||||
my $b = WebGUI::SQL->read($sql);
|
||||
while (my ($id, $class, $version) = $b->array) {
|
||||
WebGUI::Asset::Post->new($id,$class,$version)->setStatusArchived;
|
||||
while (my ($id, $version) = $b->array) {
|
||||
my $post = WebGUI::Asset::Post->new($id,undef,$version);
|
||||
$post->setStatusArchived if (defined $post && $post->get("dateUpdated") < $archiveDate);
|
||||
}
|
||||
$b->finish;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue