summaryrefslogtreecommitdiff
path: root/lib/Multi
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Multi')
-rw-r--r--lib/Multi/IRC.pm11
-rw-r--r--lib/Multi/Maintenance.pm23
2 files changed, 25 insertions, 9 deletions
diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm
index 224b35d4..e408a3cc 100644
--- a/lib/Multi/IRC.pm
+++ b/lib/Multi/IRC.pm
@@ -57,7 +57,7 @@ sub spawn {
sub _start {
$_[KERNEL]->alias_set('irc');
- $_[KERNEL]->call(core => register => qr/^ircnotify ([vrpt][0-9]+\.[0-9]+)$/, 'ircnotify');
+ $_[KERNEL]->call(core => register => qr/^ircnotify ([vrptg][0-9]+(?:\.[0-9]+)?)$/, 'ircnotify');
$_[HEAP]{irc}->plugin_add(
Logger => POE::Component::IRC::Plugin::Logger->new(
@@ -167,7 +167,7 @@ sub vndbid { # dest, msg, force
for (keys %{$_[HEAP]{log}});
# Four possible options:
- # 1. [tvpru]+ -> item/user/thread (nf)
+ # 1. [tvprug]+ -> item/user/thread/tag (nf)
# 2. [vprt]+.+ -> revision/reply (ef)
# 3. d+ -> documentation page (nf)
# 4. d+.+ -> documentation page # section (sf)
@@ -184,7 +184,7 @@ sub vndbid { # dest, msg, force
for (split /[, ]/, $m) {
next if length > 15 or m{[a-z]{3,6}://}i; # weed out URLs and too long things
push @id, /^(?:.*[^\w]|)([dvprt])([1-9][0-9]*)\.([1-9][0-9]*)(?:[^\w].*|)$/ ? [ $1, $2, $3 ] # matches 2 and 4
- : /^(?:.*[^\w]|)([dvprtu])([1-9][0-9]*)(?:[^\w].*|)$/ ? [ $1, $2, 0 ] : (); # matches 1 and 3
+ : /^(?:.*[^\w]|)([dvprtug])([1-9][0-9]*)(?:[^\w].*|)$/ ? [ $1, $2, 0 ] : (); # matches 1 and 3
}
# loop through the matched IDs and search the database
@@ -194,13 +194,14 @@ sub vndbid { # dest, msg, force
next if $_[HEAP]{log}{$t.$id.'.'.$rev} && !$_[ARG2];
$_[HEAP]{log}{$t.$id.'.'.$rev} = time;
- # option 1: item/user/thread
- if($t =~ /[vprtu]/ && !$rev) {
+ # option 1: item/user/thread/tag
+ if($t =~ /[vprtug]/ && !$rev) {
my $s = $Multi::SQL->prepare(
$t eq 'v' ? 'SELECT vr.title FROM vn_rev vr JOIN vn v ON v.latest = vr.id WHERE v.id = ?' :
$t eq 'u' ? 'SELECT u.username AS title FROM users u WHERE u.id = ?' :
$t eq 'p' ? 'SELECT pr.name AS title FROM producers_rev pr JOIN producers p ON p.latest = pr.id WHERE p.id = ?' :
$t eq 't' ? 'SELECT title FROM threads WHERE id = ?' :
+ $t eq 'g' ? 'SELECT name AS title FROM tags WHERE id = ?' :
'SELECT rr.title FROM releases_rev rr JOIN releases r ON r.latest = rr.id WHERE r.id = ?'
);
$s->execute($id);
diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm
index e9c9b337..51c6cec8 100644
--- a/lib/Multi/Maintenance.pm
+++ b/lib/Multi/Maintenance.pm
@@ -18,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 vnpopularity |],
+ $p => [qw| _start cmd_maintenance vncache usercache statscache revcache integrity unkanime logrotate vnpopularity tagcache |],
],
);
}
@@ -26,8 +26,10 @@ sub spawn {
sub _start {
$_[KERNEL]->alias_set('maintenance');
- $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:vncache|revcache|usercache|statscache|integrity|unkanime|logrotate|vnpopularity))+)$/, 'cmd_maintenance');
-
+ $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:vncache|revcache|usercache|statscache|integrity|unkanime|logrotate|vnpopularity|tagcache))+)$/, 'cmd_maintenance');
+
+ # recalculate tag<->vn cache each hour (better do this once every 24 hours when the DB grows)
+ $_[KERNEL]->post(core => addcron => '0 * * * *', 'maintenance tagcache');
# Perform some maintenance functions every day on 0:00
$_[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
@@ -64,6 +66,12 @@ sub usercache {
FROM changes
WHERE requester = users.id
GROUP BY requester
+ ), 0),
+ c_tags = COALESCE(
+ (SELECT COUNT(tag)
+ FROM tags_vn
+ WHERE uid = users.id
+ GROUP BY uid
), 0)
|);
}
@@ -132,7 +140,7 @@ sub unkanime {
WHERE a.lastfetch < 0|);
$q->execute();
my $r = $q->fetchall_arrayref([]);
- my %aid = map {
+ my %aid = map {
my $a=$_;
$a->[1] => join(',', map { $a->[1] == $_->[1] ? $_->[0] : () } @$r)
} @$r;
@@ -177,6 +185,13 @@ sub vnpopularity {
}
+sub tagcache {
+ my $S = [gettimeofday];
+ $Multi::SQL->do(q|SELECT tag_vn_calc()|);
+ $_[KERNEL]->call(core => log => 3 => '(Re)calculated tags_vn_stored in %.2fs', tv_interval($S));
+}
+
+
1;