+ update README for config options + cron jobs
This commit is contained in:
Luc Didry
2014-02-20 01:14:26 +01:00
parent 96072d0a2a
commit 2c9eca80e3
3 changed files with 64 additions and 2 deletions
+38
View File
@@ -0,0 +1,38 @@
package Mojolicious::Command::cron::cleanbdd;
use Mojo::Base 'Mojolicious::Command';
use LutimModel;
use Mojo::Util qw(slurp decode);
use Mojolicious::Plugin::Config;
has description => 'Delete IP addresses from database after configured delay.';
has usage => sub { shift->extract_usage };
sub run {
my $c = shift;
my $config = Mojolicious::Plugin::Config->parse(decode('UTF-8', slurp 'lutim.conf'), 'lutim.conf');
$config->{keep_ip_during} = (defined($config->{keep_ip_during})) ? $config->{keep_ip_during} : 365;
my $separation = time() - $config->{keep_ip_during} * 86400;
LutimModel->do(
'UPDATE lutim SET created_by = "" WHERE path IS NOT NULL AND created_at < ?',
{},
$separation
);
}
=encoding utf8
=head1 NAME
Mojolicious::Command::cron::cleanbdd - Delete IP addresses from database after configured delay
=head1 SYNOPSIS
Usage: script/lutim cron cleanbdd
=cut
1;