initial coding on activities
lots of debugging
This commit is contained in:
parent
cd66dbb780
commit
debcdd08a5
7 changed files with 88 additions and 39 deletions
|
|
@ -72,29 +72,35 @@ sub execute {
|
|||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
return $self->ERROR;
|
||||
|
||||
# keep track of how much time it's taking
|
||||
my $start = time;
|
||||
my $limit = 2_500;
|
||||
my $timeLimit = 120;
|
||||
|
||||
my $list = $root->getLineage( ['children'], { returnObjects => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
|
||||
my $sth = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::HelpDesk'");
|
||||
while (my ($assetId) = $sth->array) {
|
||||
my $hd = WebGUI::Asset->new($session,$assetId,"WebGUI::Asset::Wobject::HelpDesk");
|
||||
next unless defined $hd;
|
||||
|
||||
my $closeAfter = $hd->get("closeTicketsAfter");
|
||||
|
||||
my $rules = {};
|
||||
$rules->{'joinClass' } = "WebGUI::Asset::Ticket";
|
||||
$rules->{'whereClause' } = qq{Ticket.ticketStatus = 'resolved' and (Ticket.resolvedDate + $closeAfter <= UNIX_TIMESTAMP(NOW()))};
|
||||
$rules->{'includeOnlyClasses'} = ['WebGUI::Asset::Ticket'];
|
||||
$rules->{'returnObjects' } = 1;
|
||||
|
||||
my $tickets = $hd->getLineage(['children'], $rules);
|
||||
foreach my $ticket (@{$tickets}) {
|
||||
$ticket->setStatus("closed");
|
||||
}
|
||||
for my $emsf ( @$list ) {
|
||||
my whereClause = q{ ( submissionStatus='denied' }
|
||||
if( $emsf->get('deleteCreatedItems') ) {
|
||||
$whereClause .= q{ or submissionStatus='created'};
|
||||
}
|
||||
my $checkDate = time - ( 60*60*24* $emsf->get('daysBeforeCleanup') );
|
||||
$whereClause .= q{ ) and lastModifiedDate < } . $checkDate;
|
||||
my $res = $emsf->getLineage(['children'],{
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||
whereClause => $whereClause,
|
||||
} );
|
||||
for my $submission ( @$res ) {
|
||||
$submission->purge;
|
||||
$limit--;
|
||||
return $self->WAITING(1) if ! $limit or time > $start + $timeLimit;
|
||||
}
|
||||
}
|
||||
return $self->COMPLETE;
|
||||
return $self->COMPLETE;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,44 @@ See WebGUI::Workflow::Activity::execute() for details.
|
|||
|
||||
=cut
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
|
||||
# keep track of how much time it's taking
|
||||
my $start = time;
|
||||
my $limit = 2_500;
|
||||
my $timeLimit = 120;
|
||||
|
||||
my $list = $root->getLineage( ['children'], { returnObjects => 1,
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
|
||||
} );
|
||||
|
||||
for my $emsf ( @$list ) {
|
||||
my whereClause = q{ ( submissionStatus='approved' }
|
||||
my $res = $emsf->getLineage(['children'],{
|
||||
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
|
||||
whereClause => $whereClause,
|
||||
} );
|
||||
for my $submission ( @$res ) {
|
||||
my %properties = $submission->get;
|
||||
delete $properties{submissionId};
|
||||
delete $properties{submissionStatus};
|
||||
delete $properties{sendEmailOnChange};
|
||||
delete $properties{ticketId};
|
||||
my $ticketId = $emsf->ems->addChild(
|
||||
className => 'WebGUI::Asset::Sku::EMSTicket',
|
||||
%properties;
|
||||
);
|
||||
$submission->update({ ticketId => $ticketId });
|
||||
$limit--;
|
||||
return $self->WAITING(1) if ! $limit or time > $start + $timeLimit;
|
||||
}
|
||||
}
|
||||
return $self->COMPLETE;
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue