diff options
Diffstat (limited to 'lib/Multi/Maintenance.pm')
-rw-r--r-- | lib/Multi/Maintenance.pm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm index 4f816e56..0ea7ef29 100644 --- a/lib/Multi/Maintenance.pm +++ b/lib/Multi/Maintenance.pm @@ -17,12 +17,12 @@ sub spawn { package_states => [ $p => [qw| _start shutdown set_daily daily set_monthly monthly log_stats - vncache tagcache vnpopularity cleangraphs + vncache tagcache vnpopularity vnrating cleangraphs usercache statscache logrotate |], ], heap => { - daily => [qw|vncache tagcache vnpopularity cleangraphs|], + daily => [qw|vncache tagcache vnpopularity vnrating cleangraphs|], monthly => [qw|usercache statscache logrotate|], @_, }, @@ -117,6 +117,20 @@ sub vnpopularity { } +sub vnrating { + # takes less than a second, but can be performed in ranges as well when necessary + $_[KERNEL]->post(pg => do => q| + UPDATE vn SET + c_rating = (SELECT ( + ((SELECT COUNT(vote)::real/COUNT(DISTINCT vid)::real FROM votes)*(SELECT AVG(a)::real FROM (SELECT AVG(vote) FROM votes GROUP BY vid) AS v(a)) + SUM(vote)::real) / + ((SELECT COUNT(vote)::real/COUNT(DISTINCT vid)::real FROM votes) + COUNT(uid)::real) + ) FROM votes WHERE vid = id AND uid NOT IN(SELECT id FROM users WHERE ign_votes) + ), + c_votecount = COALESCE((SELECT count(*) FROM votes WHERE vid = id AND uid NOT IN(SELECT id FROM users WHERE ign_votes)), 0) + |, undef, 'log_stats', 'vnrating'); +} + + sub cleangraphs { # should be pretty fast $_[KERNEL]->post(pg => do => q| |