summaryrefslogtreecommitdiff
path: root/lib/Multi/Maintenance.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Multi/Maintenance.pm')
-rw-r--r--lib/Multi/Maintenance.pm43
1 files changed, 37 insertions, 6 deletions
diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm
index fb74e192..51fff936 100644
--- a/lib/Multi/Maintenance.pm
+++ b/lib/Multi/Maintenance.pm
@@ -11,10 +11,12 @@ use POE;
sub spawn {
+ # WARNING: these maintenance tasks can block the process for a few seconds
+
my $p = shift;
POE::Session->create(
package_states => [
- $p => [qw| _start cmd_maintenance vncache ratings prevcache integrity |],
+ $p => [qw| _start cmd_maintenance vncache ratings prevcache integrity unkanime |],
],
);
}
@@ -22,7 +24,7 @@ sub spawn {
sub _start {
$_[KERNEL]->alias_set('maintenance');
- $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:all|vncache|ratings|prevcache|integrity))+)$/, 'cmd_maintenance');
+ $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:all|vncache|ratings|prevcache|integrity|unkanime))+)$/, 'cmd_maintenance');
# Perform all maintenance functions every day on 0:00
$_[KERNEL]->post(core => addcron => '0 0 * * *', 'maintenance all');
@@ -32,10 +34,11 @@ sub _start {
sub cmd_maintenance {
local $_ = $_[ARG1];
- $_[KERNEL]->yield('vncache') if /(vncache|all)/;
- $_[KERNEL]->yield('ratings') if /(ratings|all)/;
- $_[KERNEL]->yield('prevcache') if /(prevcache|all)/;
- $_[KERNEL]->yield('integrity') if /(integrity|all)/;
+ $_[KERNEL]->yield('vncache') if /(?:vncache|all)/;
+ $_[KERNEL]->yield('ratings') if /(?:ratings|all)/;
+ $_[KERNEL]->yield('prevcache') if /(?:prevcache|all)/;
+ $_[KERNEL]->yield('integrity') if /(?:integrity|all)/;
+ $_[KERNEL]->yield('unkanime') if /(?:unkanime|all)/;
$_[KERNEL]->post(core => finish => $_[ARG0]);
}
@@ -55,6 +58,7 @@ sub ratings {
sub prevcache {
$_[KERNEL]->call(core => log => 3 => 'Updating prev column in the changes table...');
+ # this can take a while, maybe split these up in 3 queries?
$Multi::SQL->do(q|SELECT update_prev('vn', ''), update_prev('releases', ''), update_prev('producers', '')|);
}
@@ -79,6 +83,33 @@ sub integrity {
}
+sub unkanime {
+ # warn for VNs with a non-existing anidb id
+ # (maybe do an automated edit or something in the future)
+
+ my $q = $Multi::SQL->prepare(q|
+ SELECT v.id, va.aid
+ FROM vn_anime va
+ JOIN vn v ON va.vid = v.latest
+ JOIN anime a ON va.aid = a.id
+ WHERE a.lastfetch < 0|);
+ $q->execute();
+ my $r = $q->fetchall_arrayref([]);
+ my %aid = map {
+ my $a=$_;
+ $a->[1] => join(',', map { $a->[1] == $_->[1] ? $_->[0] : () } @$r)
+ } @$r;
+
+ if(keys %aid) {
+ $_[KERNEL]->call(core => log => 1, '!NON-EXISTING RELATED ANIME FOUND!: %s',
+ join('; ', map { 'a'.$_.':v'.$aid{$_} } keys %aid)
+ );
+ } else {
+ $_[KERNEL]->call(core => log => 3, 'No problems found with the related anime');
+ }
+}
+
+
1;