Changeset 230


Ignore:
Timestamp:
Oct 29, 2006, 6:10:20 PM (13 years ago)
Author:
Dominic Hargreaves
Message:

Better stats stuff

Location:
trunk/npemap.org.uk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/perllib/NPEMap/Config.pm

    r226 r230  
    11package NPEMap::Config;
    22
    3 use vars qw(@ISA @EXPORT $tt_config $rootdir $dbname);
     3use vars qw(@ISA @EXPORT $tt_config $rootdir);
    44use warnings;
    55use strict;
     
    99require Exporter;
    1010@ISA    = qw(Exporter);
    11 @EXPORT = qw($tt_config $dbname $dbhost $dbuser $dbpass);
     11@EXPORT = qw($tt_config $dbname $dbhost $dbuser $dbpass $staticdir);
    1212
    1313# Read in site config
  • trunk/npemap.org.uk/perllib/NPEMap/Postcodes.pm

    r219 r230  
    6868        datestats => $dateStats
    6969    };
    70     $template->process('home_stats.tt', $vars) or die $template->error();
     70   
     71    $template->process('home_stats.tt', $vars, $staticdir . '/stats.html')
     72        or warn $template->error();
    7173}
    7274
  • trunk/npemap.org.uk/scripts/content/update_stats.pl

    r220 r230  
    1313use lib "$FindBin::Bin/../../perllib";
    1414use NPEMap::Postcodes;
    15 
    16 use vars qw($dbname $dbhost $dbuser $dbpass);
     15use NPEMap;
    1716
    1817sub print_err;
    1918sub setup_dbh;
    2019
    21 # Read in database config
    22 my $config = 'npemap.conf';
    23 do $config or die "Can't read $config!\n";
    24 
    25 
    26 # No point in handling errors here since they'll get handled by the request
    27 # handler
    2820my $dbh;
    2921
    30 
    3122    # In case the database went away, make sure we have a connection
    32     unless (setup_dbh()) {
     23    unless ($dbh = setup_dbh()) {
    3324        print_internal_err('Error setting up database connection');
    3425    }
     
    3627build_home_stats($dbh);
    3728
    38 
    39 # No more requests to serve, so tidy up
    4029$dbh->disconnect;
    4130
     
    5241    print "Error: $err\n";
    5342}
    54 
    55 sub setup_dbh {
    56     # $dbh is global
    57     my $data_source = "dbi:Pg:dbname=$dbname";
    58     $data_source .= ";host=$dbhost" if $dbhost;
    59     return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);
    60 }
  • trunk/npemap.org.uk/templates/home_stats.tt

    r219 r230  
    1 Total postcodes collected by us: [% allstats.us %]
    2 Outward parts collected by us: [% allstats.us_out %]
    3 
     1<ul>
     2<li>Total postcodes collected: [% allstats.us %]</li>
     3<li>Outward parts collected: [% allstats.us_out %]</li>
     4</ul>
Note: See TracChangeset for help on using the changeset viewer.