diff options
author | Yorhel <git@yorhel.nl> | 2008-10-27 19:19:47 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2008-10-27 19:19:47 +0100 |
commit | f266cd214111a1c71f705edbc9243d8625693003 (patch) | |
tree | c9ba1eb4de5b3b6f2f5b369b5b5a0c2917a62755 /lib/VNDB/DB/Misc.pm | |
parent | 0c5411d6da14c641efc9ae8f0e50ca047f6c8c22 (diff) |
Database statistics are now fetched from the DB
...and I created yet another *::Misc module...
Diffstat (limited to 'lib/VNDB/DB/Misc.pm')
-rw-r--r-- | lib/VNDB/DB/Misc.pm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/VNDB/DB/Misc.pm b/lib/VNDB/DB/Misc.pm new file mode 100644 index 00000000..50a12a4b --- /dev/null +++ b/lib/VNDB/DB/Misc.pm @@ -0,0 +1,27 @@ + +package VNDB::DB::Misc; + +use strict; +use warnings; +use Exporter 'import'; + +our @EXPORT = qw| + dbStats +|; + + +# Arguments: array of elements to get stats from, options: +# vn, producers, releases, users, threads, posts +# Returns: hashref, key = element, value = number of entries +sub dbStats { + my $s = shift; + return { map { + $_ => $s->dbRow('SELECT COUNT(*) as cnt FROM !s !W', + /posts/ ? 'threads_posts' : $_, + /producers|vn|releases|threads|posts/ ? { 'hidden = ?' => 0 } : {} + )->{cnt} - (/users/ ? 1 : 0); + } @_ }; +} + +1; + |