summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-04-09 08:34:40 +0200
committerYorhel <git@yorhel.nl>2020-04-09 08:35:32 +0200
commit6fd9ceb051538f11829b7d9b2919665dbeca70ed (patch)
tree5944f52bd30a92aa56bb165e5db4674d527660cf /lib
parent443fc2d8bc509b2231b4b34cb420b84d158a1b02 (diff)
Stop keeping track of users/threads/posts count cache
Those stats havent been displayed on the site for ages, anyway. The API will now report '0' for these stats.
Diffstat (limited to 'lib')
-rw-r--r--lib/Multi/API.pm3
-rw-r--r--lib/VNDB/DB/Misc.pm12
-rw-r--r--lib/VNWeb/Discussions/Edit.pm1
-rw-r--r--lib/VNWeb/HTML.pm15
-rw-r--r--lib/VNWeb/User/List.pm3
5 files changed, 12 insertions, 22 deletions
diff --git a/lib/Multi/API.pm b/lib/Multi/API.pm
index 22152aa0..518d32bc 100644
--- a/lib/Multi/API.pm
+++ b/lib/Multi/API.pm
@@ -337,8 +337,7 @@ sub dbstats {
cpg $c, 'SELECT section, count FROM stats_cache', undef, sub {
my $res = shift;
- cres $c, [ dbstats => { map {
- $_->{section} =~ s/^threads_//;
+ cres $c, [ dbstats => { users => 0, threads => 0, posts => 0, map {
($_->{section}, 1*$_->{count})
} $res->rowsAsHashes } ], 'dbstats';
};
diff --git a/lib/VNDB/DB/Misc.pm b/lib/VNDB/DB/Misc.pm
index 74d2b15e..e089f3fb 100644
--- a/lib/VNDB/DB/Misc.pm
+++ b/lib/VNDB/DB/Misc.pm
@@ -6,20 +6,10 @@ use warnings;
use Exporter 'import';
our @EXPORT = qw|
- dbStats dbItemEdit dbRevisionGet dbWikidata dbImageAdd
+ dbItemEdit dbRevisionGet dbWikidata dbImageAdd
|;
-# Returns: hashref, key = section, value = number of (visible) entries
-# Sections: vn, producers, releases, users, threads, posts
-sub dbStats {
- my $s = shift;
- return { map {
- $_->{section} eq 'threads_posts' ? 'posts' : $_->{section}, $_->{count}
- } @{$s->dbAll('SELECT * FROM stats_cache')}};
-}
-
-
# Inserts a new revision into the database
# Arguments: type [vrpcsd], itemid, rev, %options->{ editsum uid ihid ilock + db[item]RevisionInsert }
# rev = changes.rev of the revision this edit is based on, undef to create a new DB item
diff --git a/lib/VNWeb/Discussions/Edit.pm b/lib/VNWeb/Discussions/Edit.pm
index a0627448..40f13a74 100644
--- a/lib/VNWeb/Discussions/Edit.pm
+++ b/lib/VNWeb/Discussions/Edit.pm
@@ -52,7 +52,6 @@ elm_api DiscussionsEdit => $FORM_OUT, $FORM_IN, sub {
if($data->{delete} && auth->permBoardmod) {
warn "AUDIT: Delete t$tid.$num\n";
- # BUG: Doesn't cause stats_cache to be updated. But who cares about that.
if($num == 1) {
# (This could be a single query if there were proper ON DELETE CASCADE in the DB, though that's hard for notifications...)
tuwf->dbExeci('DELETE FROM threads_posts WHERE tid =', \$tid);
diff --git a/lib/VNWeb/HTML.pm b/lib/VNWeb/HTML.pm
index c33baccc..6cca2164 100644
--- a/lib/VNWeb/HTML.pm
+++ b/lib/VNWeb/HTML.pm
@@ -265,15 +265,16 @@ sub _menu_ {
h2_ 'Database Statistics';
div_ sub {
dl_ sub {
- dt_ 'Visual Novels'; dd_ tuwf->{stats}{vn};
+ my %stats = map +($_->{section}, $_->{count}), tuwf->dbAll('SELECT * FROM stats_cache')->@*;
+ dt_ 'Visual Novels'; dd_ $stats{vn};
dt_ sub { b_ class => 'grayedout', '> '; lit_ 'Tags' };
- dd_ tuwf->{stats}{tags};
- dt_ 'Releases'; dd_ tuwf->{stats}{releases};
- dt_ 'Producers'; dd_ tuwf->{stats}{producers};
- dt_ 'Staff'; dd_ tuwf->{stats}{staff};
- dt_ 'Characters'; dd_ tuwf->{stats}{chars};
+ dd_ $stats{tags};
+ dt_ 'Releases'; dd_ $stats{releases};
+ dt_ 'Producers'; dd_ $stats{producers};
+ dt_ 'Staff'; dd_ $stats{staff};
+ dt_ 'Characters'; dd_ $stats{chars};
dt_ sub { b_ class => 'grayedout', '> '; lit_ 'Traits' };
- dd_ tuwf->{stats}{traits};
+ dd_ $stats{traits};
};
clearfloat_;
}
diff --git a/lib/VNWeb/User/List.pm b/lib/VNWeb/User/List.pm
index d285d4b5..42e61f16 100644
--- a/lib/VNWeb/User/List.pm
+++ b/lib/VNWeb/User/List.pm
@@ -86,7 +86,8 @@ TUWF::get qr{/u/(?<char>[0a-z]|all)}, sub {
images => 'c_imgvotes',
}->{$opt->{s}}, $opt->{o} eq 'd' ? 'DESC' : 'ASC'
);
- my $count = @where ? tuwf->dbVali('SELECT count(*) FROM users WHERE', sql_and @where) : tuwf->{stats}{users};
+ state $totalusers = tuwf->dbVal('SELECT count(*) FROM users');
+ my $count = @where ? tuwf->dbVali('SELECT count(*) FROM users WHERE', sql_and @where) : $totalusers;
framework_ title => 'Browse users', sub {
div_ class => 'mainbox', sub {