migrated a few of the run hourly scripts

fixed a cron bug
This commit is contained in:
JT Smith 2006-02-18 14:38:09 +00:00
parent a50a190642
commit e04a1b6fca
25 changed files with 766 additions and 256 deletions

View file

@ -0,0 +1,93 @@
package WebGUI::Workflow::Activity::CleanFileCache;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::Cache::FileCache;
=head1 NAME
Package WebGUI::Workflow::Activity::CleanFileCache
=head1 DESCRIPTION
This activity deletes files from the file cache if the file cache has gotten too big.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Workflow_Activity_CleanFileCache");
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> {
sizeLimit => {
fieldType=>"integer",
label=>$i18n->get("size limit"),
subtext=>$i18n->get("bytes"),
defaultValue=>100000000,
hoverHelp=>$i18n->get("size limit help")
}
}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $size = $self->get("sizeLimit") + 10;
my $expiresModifier = 0;
my $cache = WebGUI::Cache::FileCache->new;
while ($size > $self->get("sizeLimit")) {
$size = $cache->getNamespaceSize($expiresModifier);
$expiresModifier += 60 * 30; # add 30 minutes each pass
}
}
1;

View file

@ -0,0 +1,85 @@
package WebGUI::Workflow::Activity::CleanLoginHistory;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
=head1 NAME
Package WebGUI::Workflow::Activity::CleanLoginHistory
=head1 DESCRIPTION
Deletes some of the old cruft from the userLoginLog table.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Workflow_Activity_CleanLoginHistory");
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> {
ageToDelete => {
fieldType=>"interval",
label=>$i18n->get("age to delete"),
defaultValue=>60 * 60 * 24 * 90,
hoverHelp=>$i18n->get("age to delete help")
}
}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
$self->session->db->write("delete from userLoginLog where timeStamp < ?", [(time()-(86400*$self->get("ageToDelete")))]);
}
1;

View file

@ -1,4 +1,4 @@
package WebGUI::Workflow::Activity::CleanCommitVersionTag;
package WebGUI::Workflow::Activity::CommitVersionTag;
=head1 LEGAL

View file

@ -0,0 +1,91 @@
package WebGUI::Workflow::Activity::DecayKarma;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
=head1 NAME
Package WebGUI::Workflow::Activity::DecayKarma
=head1 DESCRIPTION
Subtracts a little bit of karma from each user. This can be used to slowly degrade the abilities of the users who stay away from the site for a long period of time.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Workflow_Activity_DecayKarma");
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> {
minimumKarma => {
fieldType=>"integer",
label=>$i18n->get("minimum karma"),
defaultValue=>0,
hoverHelp=>$i18n->get("minimum karma help")
},
decayFactor => {
fieldType=>"integer",
label=>$i18n->get("decay factor"),
defaultValue=>1,
hoverHelp=>$i18n->get("decay factor help")
}
}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
$self->session->db->write("update users set karma=karma-? where karma > ?", [$self->get("decayFactor"), $self->get("minimumKarma")]);
}
1;

View file

@ -0,0 +1,81 @@
package WebGUI::Workflow::Activity::RollbackVersionTag;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::VersionTag;
=head1 NAME
Package WebGUI::Workflow::Activity::RollbackVersionTag
=head1 DESCRIPTION
This activity rolls back a version tag.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Workflow_Activity_RollbackVersionTag");
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> { }
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $versionTag = shift;
$versionTag->rollback;
}
1;

View file

@ -0,0 +1,90 @@
package WebGUI::Workflow::Activity::TrashClipboard;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
=head1 NAME
Package WebGUI::Workflow::Activity::TrashClipboard;
=head1 DESCRIPTION
Deletes
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, "Workflow_Activity_TrashClipboard");
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> {
trashAfter => {
fieldType=>"interval",
label=>$i18n->get("trash after"),
defaultValue=>60 * 60 * 24 * 30,
hoverHelp=>$i18n->get("trash after help")
}
}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
my $expireDate = (time()-(86400*$self->get("trashAfter")));
my $sth = $self->session->db->read("select assetId,className from asset where state='clipboard' and stateChanged < ?", [$expireDate]);
while (my ($id, $class) = $sth->array) {
my $asset = WebGUI::Asset->new($id,$class);
$asset->trash;
}
}
1;

View file

@ -0,0 +1,84 @@
package WebGUI::Workflow::Activity::Skeleton; # change "Skeleton" to your namespace.
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use base 'WebGUI::Workflow::Activity';
=head1 NAME
Package WebGUI::Workflow::Activity::Skeleton
=head1 DESCRIPTION
Tell a little about what this activity does.
=head1 SYNOPSIS
See WebGUI::Workflow::Activity for details on how to use any activity.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( session, definition )
See WebGUI::Workflow::Activity::defintion() for details.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
push(@{$definition}, {
name=>$i18n->get("topicName"),
properties=> {
someField => {
fieldType=>"integer",
label=>"Some Field"
defaultValue=>0,
hoverHelp=>"Hover help for some field."
},
}
});
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 execute ( [ object ] )
See WebGUI::Workflow::Activity::execute() for details.
=cut
sub execute {
my $self = shift;
# do some work here, whatever this activity is supposed to do
}
1;

View file

@ -246,11 +246,23 @@ sub set {
}
$self->{_data}{title} = $properties->{title} || $self->{_data}{title} || "Untitled";
$self->{_data}{priority} = $properties->{priority} || $self->{_data}{priority} || 2;
$self->{_data}{minuteOfHour} = $properties->{minuteOfHour} || $self->{_data}{minuteOfHour} || 0;
$self->{_data}{hourOfDay} = $properties->{hourOfDay} || $self->{_data}{hourOfDay} || "*";
$self->{_data}{dayOfMonth} = $properties->{dayOfMonth} || $self->{_data}{dayOfMonth} || "*";
$self->{_data}{monthOfYear} = $properties->{monthOfYear} || $self->{_data}{monthOfYear} || "*";
$self->{_data}{dayOfWeek} = $properties->{dayOfWeek} || $self->{_data}{dayOfWeek} || "*";
if ($properties->{minuteOfHour} ne "") {
$self->{_data}{minuteOfHour} = $properties->{minuteOfHour};
} elsif ($self->{_data}{minuteOfHour} eq "") {
$self->{_data}{minuteOfHour} = "0";
}
if ($properties->{hourOfDay} ne "") {
$self->{_data}{hourOfDay} = $properties->{hourOfDay};
} elsif ($self->{_data}{hourOfDay} eq "") {
$self->{_data}{hourOfDay} = "*";
}
if ($properties->{dayOfWeek} ne "") {
$self->{_data}{dayOfWeek} = $properties->{dayOfWeek};
} elsif ($self->{_data}{dayOfWeek} eq "") {
$self->{_data}{dayOfWeek} = "*";
}
$self->{_data}{workflowId} = $properties->{workflowId} || $self->{_data}{workflowId};
$self->{_data}{className} = (exists $properties->{className}) ? $properties->{className} : $self->{_data}{className};
$self->{_data}{methodName} = (exists $properties->{methodName}) ? $properties->{methodName} : $self->{_data}{methodName};