Cache stats in the database (and auto-update them from cron)
This commit is contained in:
parent
f6564dfd9c
commit
0738583243
3 changed files with 18 additions and 5 deletions
|
|
@ -56,6 +56,8 @@ CREATE INDEX ON man (name);
|
||||||
CREATE TABLE man_index AS SELECT DISTINCT name, section FROM man;
|
CREATE TABLE man_index AS SELECT DISTINCT name, section FROM man;
|
||||||
CREATE INDEX ON man_index USING btree(lower(name) text_pattern_ops);
|
CREATE INDEX ON man_index USING btree(lower(name) text_pattern_ops);
|
||||||
|
|
||||||
|
CREATE TABLE stats_cache AS SELECT count(distinct hash) AS hashes, count(distinct name) AS mans, count(*) AS files, count(distinct package) AS packages FROM man;
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO systems (id, name, release, short, relorder) VALUES
|
INSERT INTO systems (id, name, release, short, relorder) VALUES
|
||||||
(1, 'Arch Linux', NULL, 'arch', 0),
|
(1, 'Arch Linux', NULL, 'arch', 0),
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,9 @@ CREATE INDEX ON man_index_new USING btree(lower(name) text_pattern_ops);
|
||||||
DROP TABLE man_index;
|
DROP TABLE man_index;
|
||||||
ALTER TABLE man_index_new RENAME TO man_index;
|
ALTER TABLE man_index_new RENAME TO man_index;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
CREATE TABLE stats_cache_new AS SELECT count(distinct hash) AS hashes, count(distinct name) AS mans, count(*) AS files, count(distinct package) AS packages FROM man;
|
||||||
|
DROP TABLE stats_cache;
|
||||||
|
ALTER TABLE stats_cache_new RENAME TO stats_cache;
|
||||||
|
COMMIT;
|
||||||
|
|
|
||||||
15
www/index.pl
15
www/index.pl
|
|
@ -54,13 +54,13 @@ TUWF::run();
|
||||||
|
|
||||||
sub home {
|
sub home {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
my $stats = $self->dbStats;
|
||||||
|
my $fn = sub { local $_=shift; 1 while(s/(\d)(\d{3})($|,)/$1,$2/); $_ };
|
||||||
$self->htmlHeader(title => 'Man Pages Archive');
|
$self->htmlHeader(title => 'Man Pages Archive');
|
||||||
h1 'Man Pages Archive';
|
h1 'Man Pages Archive';
|
||||||
# Relevant query: SELECT count(distinct hash), count(distinct name), count(*), count(distinct package) FROM man;
|
p style => 'float: none'; lit sprintf <<' _', map $fn->($stats->{$_}), qw|hashes mans files packages|;
|
||||||
# It's far too slow to run that on every pageview. :-(
|
Indexing <b>%s</b> versions of <b>%s</b> manual pages found in <b>%s</b>
|
||||||
p style => 'float: none'; lit <<' _';
|
files of <b>%s</b> packages.
|
||||||
Indexing <b>679,885</b> versions of <b>132,493</b> manual pages found in
|
|
||||||
<b>2,213,486</b> files of <b>222,543</b> packages.
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
Manned.org aims to index all manual pages from a variety of systems, both
|
Manned.org aims to index all manual pages from a variety of systems, both
|
||||||
old and new, and provides a convenient interface for looking up and viewing
|
old and new, and provides a convenient interface for looking up and viewing
|
||||||
|
|
@ -684,3 +684,8 @@ sub dbPackageGet {
|
||||||
$sysid, $name)
|
$sysid, $name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub dbStats {
|
||||||
|
return $_[0]->dbRow('SELECT * FROM stats_cache');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue