From 9304d1032723d3c2b9f3dad4d239f12c8c7268fa Mon Sep 17 00:00:00 2001 From: Yorhel Date: Fri, 8 Apr 2011 19:25:53 +0200 Subject: Update traits_chars cache daily using Multi::Maintenance I'd really prefer incremental updates, but I'll first need to find a proper algorithm... --- ChangeLog | 1 + data/lang.txt | 7 +++++++ lib/Multi/Maintenance.pm | 14 ++++++++++---- lib/VNDB/Handler/Chars.pm | 4 ---- lib/VNDB/Handler/Traits.pm | 6 +----- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59185a2e..a8ce144a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ - CSS: Hide links in [spoiler] tags - Added 'select' all to wishlist and moved 'select all' down on notifies - Added char/tag/trait stats to database statistics box + - Update traits_chars cache daily using Multi::Maintenance - Bugfix: don't accidentally remove char traits when editing - Bugfix: fixed possible SQL table name clash on history browser - Bugfix: properly announce chars and traits in Multi::IRC diff --git a/data/lang.txt b/data/lang.txt index bee15a28..b4951352 100644 --- a/data/lang.txt +++ b/data/lang.txt @@ -5696,6 +5696,13 @@ cs : Tato vlastnost ještě nebyla provázána s žádnými postavami nebo tyto hu : Ez a sajátosság még nincs hozzárendelve egy szereplőhöz se, vagy a spoiler beállításaid miatt, el vannak rejtve. nl : Dit kenmerk is nog niet gekoppeld aan een karakter, of deze worden niet weergegeven in verband met je spoilerinstelling. +:_traitp_cached +en : The list below also includes all characters linked to child traits. This list is cached, it can take up to 24 hours after a character has been edited for it to show up on this page. +ru*: +cs*: +hu*: +nl : De volgende lijst bevat ook alle karakters die gelinkt zijn aan subkenmerken. Deze lijst is gecached, het kan 24 uur duren voordat een karakter op deze pagina te zien is. + # Trait add/edit form (/i+/edit, /i+/add, /i/new) diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm index 44cb6552..fb0c336f 100644 --- a/lib/Multi/Maintenance.pm +++ b/lib/Multi/Maintenance.pm @@ -18,13 +18,13 @@ sub spawn { package_states => [ $p => [qw| _start shutdown set_daily daily set_monthly monthly log_stats - vncache_inc tagcache vnpopularity vnrating cleangraphs cleansessions cleannotifications + vncache_inc tagcache traitcache vnpopularity vnrating cleangraphs cleansessions cleannotifications vncache_full usercache statscache logrotate vnsearch_check vnsearch_gettitles vnsearch_update |], ], heap => { - daily => [qw|vncache_inc tagcache vnpopularity vnrating cleangraphs cleansessions cleannotifications|], + daily => [qw|vncache_inc tagcache traitcache vnpopularity vnrating cleangraphs cleansessions cleannotifications|], monthly => [qw|vncache_full usercache statscache logrotate|], vnsearch_checkdelay => 3600, @_, @@ -121,13 +121,19 @@ sub vncache_inc { sub tagcache { - # takes about 2 seconds max, still OK + # takes about 5 seconds max, still OK $_[KERNEL]->post(pg => do => 'SELECT tag_vn_calc()', undef, 'log_stats', 'tagcache'); } +sub traitcache { + # still takes less than a second + $_[KERNEL]->post(pg => do => 'SELECT traits_chars_calc()', undef, 'log_stats', 'traitcache'); +} + + sub vnpopularity { - # still takes at most 3 seconds. let's hope that doesn't increase... + # takes a bit more than 8 seconds, meh... $_[KERNEL]->post(pg => do => 'SELECT update_vnpopularity()', undef, 'log_stats', 'vnpopularity'); } diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm index 7968b66c..dfa289be 100644 --- a/lib/VNDB/Handler/Chars.pm +++ b/lib/VNDB/Handler/Chars.pm @@ -331,10 +331,6 @@ sub edit { $frm->{vns} = \@vns; my $nrev = $self->dbItemEdit(c => !$copy && $id ? $r->{cid} : undef, %$frm); - - # TEMPORARY SOLUTION! I'll investigate more efficient solutions and incremental updates whenever I have more data - $self->dbExec('SELECT traits_chars_calc()'); - return $self->resRedirect("/c$nrev->{iid}.$nrev->{rev}", 'post'); } } diff --git a/lib/VNDB/Handler/Traits.pm b/lib/VNDB/Handler/Traits.pm index 1f3c2872..ea599ed1 100644 --- a/lib/VNDB/Handler/Traits.pm +++ b/lib/VNDB/Handler/Traits.pm @@ -104,8 +104,7 @@ sub traitpage { if(!@$chars) { p; br; br; txt mt '_traitp_nochars'; end; } - # not really cached at the moment - # p; br; txt mt '_traitp_cached'; end; + p; br; txt mt '_traitp_cached'; end; end 'div'; @$chars && $self->charBrowseTable($chars, $np, $f, "/i$trait?m=$f->{m}"); @@ -171,9 +170,6 @@ sub traitedit { } else { $self->dbTraitEdit($trait, %opts, upddate => $frm->{state} == 2 && $t->{state} != 2) if $trait; _set_childs_group($self, $trait, $group||$trait) if ($group||0) != ($t->{group}||0); - - # TEMPORARY SOLUTION! I'll investigate more efficient solutions and incremental updates whenever I have more data - $self->dbExec('SELECT traits_chars_calc()'); } $self->resRedirect("/i$trait", 'post'); return; -- cgit v1.2.3