diff --git a/schema.sql b/schema.sql index 5270a65..e79223f 100644 --- a/schema.sql +++ b/schema.sql @@ -56,6 +56,8 @@ CREATE INDEX ON man (name); CREATE TABLE man_index AS SELECT DISTINCT name, section FROM man; 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 (1, 'Arch Linux', NULL, 'arch', 0), diff --git a/util/update_indices.sql b/util/update_indices.sql index 4d452b8..a785ab7 100644 --- a/util/update_indices.sql +++ b/util/update_indices.sql @@ -7,3 +7,9 @@ CREATE INDEX ON man_index_new USING btree(lower(name) text_pattern_ops); DROP TABLE man_index; ALTER TABLE man_index_new RENAME TO man_index; 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; diff --git a/www/index.pl b/www/index.pl index ecfca63..4368211 100755 --- a/www/index.pl +++ b/www/index.pl @@ -54,13 +54,13 @@ TUWF::run(); sub home { 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'); h1 'Man Pages Archive'; - # Relevant query: SELECT count(distinct hash), count(distinct name), count(*), count(distinct package) FROM man; - # It's far too slow to run that on every pageview. :-( - p style => 'float: none'; lit <<' _'; - Indexing 679,885 versions of 132,493 manual pages found in - 2,213,486 files of 222,543 packages. + p style => 'float: none'; lit sprintf <<' _', map $fn->($stats->{$_}), qw|hashes mans files packages|; + Indexing %s versions of %s manual pages found in %s + files of %s packages.

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 @@ -684,3 +684,8 @@ sub dbPackageGet { $sysid, $name) } + +sub dbStats { + return $_[0]->dbRow('SELECT * FROM stats_cache'); +} +