Changeset 333


Ignore:
Timestamp:
Nov 5, 2006, 4:13:03 PM (13 years ago)
Author:
Dominic Hargreaves
Message:

Add missing district stats

Location:
trunk/npemap.org.uk
Files:
2 added
1 edited

Legend:

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

    r247 r333  
    99use Template;
    1010use NPEMap::Config;
     11use Date::Format;
    1112
    1213require Exporter;
    1314@ISA    = qw(Exporter);
    14 @EXPORT = qw(build_home_stats);
     15@EXPORT = qw(build_home_stats missing_district_stats);
    1516
    1617sub _getAllStats {
     
    8889}
    8990
     91sub missing_district_stats {
     92    my $dbh = shift;
     93    my $template = Template->new($tt_config);
     94
     95    my $sql = <<EOF;
     96SELECT   d.outward, d.district, d.county FROM districts AS d LEFT OUTER JOIN postcodes AS p ON (d.outward = p.outward)
     97WHERE    p.id IS NULL
     98ORDER BY d.outward
     99EOF
     100
     101    my $sth = $dbh->prepare($sql);
     102    $sth->execute or die $dbh->errstr;
     103    my $districts = $sth->fetchall_arrayref({});
     104
     105    my $vars = {
     106        districts => $districts,
     107        updated => ctime(time)
     108    };
     109
     110    $template->process('missing_district_stats.tt', $vars, $staticdir . '/stats/missing_district_stats.html')
     111        or warn $template->error();
     112}
     113
    901141;
Note: See TracChangeset for help on using the changeset viewer.