diff options
author | Yorhel <git@yorhel.nl> | 2009-01-10 10:35:28 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-01-10 10:35:28 +0100 |
commit | 08b660429d294d5347cb853de78bc285d1cd2912 (patch) | |
tree | 04e47af56f41434cbe92b373f72eb0978a20382d /lib/Multi/Maintenance.pm | |
parent | 49814b83b322adea8b2c385dfbb8300c0e2a2ebc (diff) |
Automatically recalculate the vn popularity daily using Multi::Maintenance
Diffstat (limited to 'lib/Multi/Maintenance.pm')
-rw-r--r-- | lib/Multi/Maintenance.pm | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm index 2fb7b2bd..e9c9b337 100644 --- a/lib/Multi/Maintenance.pm +++ b/lib/Multi/Maintenance.pm @@ -9,6 +9,7 @@ use strict; use warnings; use POE; use PerlIO::gzip; +use Time::HiRes 'gettimeofday', 'tv_interval'; sub spawn { @@ -17,7 +18,7 @@ sub spawn { my $p = shift; POE::Session->create( package_states => [ - $p => [qw| _start cmd_maintenance vncache usercache statscache revcache integrity unkanime logrotate |], + $p => [qw| _start cmd_maintenance vncache usercache statscache revcache integrity unkanime logrotate vnpopularity |], ], ); } @@ -25,10 +26,10 @@ sub spawn { sub _start { $_[KERNEL]->alias_set('maintenance'); - $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:vncache|revcache|usercache|statscache|integrity|unkanime|logrotate))+)$/, 'cmd_maintenance'); + $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:vncache|revcache|usercache|statscache|integrity|unkanime|logrotate|vnpopularity))+)$/, 'cmd_maintenance'); # Perform some maintenance functions every day on 0:00 - $_[KERNEL]->post(core => addcron => '0 0 * * *', 'maintenance vncache integrity unkanime'); + $_[KERNEL]->post(core => addcron => '0 0 * * *', 'maintenance vncache integrity unkanime vnpopularity'); # update caches and rotate logs every 1st day of the month at 0:05 $_[KERNEL]->post(core => addcron => '5 0 1 * *' => 'maintenance usercache statscache revcache logrotate'); } @@ -169,6 +170,13 @@ sub logrotate { } +sub vnpopularity { + my $S = [gettimeofday]; + $Multi::SQL->do(q|SELECT update_vnpopularity()|); + $_[KERNEL]->call(core => log => 3 => '(Re)calculated vn.c_popularity in %.2fs', tv_interval($S)); +} + + 1; |