Changeset 235


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

Add last 5 postcodes

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

Legend:

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

    r230 r235  
    4545    my $sth = $dbh->prepare($sql);
    4646    $sth->execute();
    47     return $sth->fetchrow_hashref;
     47    return $sth->fetchall_arrayref({});
     48}
     49
     50sub _getLastPostcodes {
     51    my $dbh = shift;
     52    my $num = shift;
     53    my $sql = <<"HERE";
     54SELECT easting, northing, outward, inward, TO_CHAR(created_at, 'DDth Mon HH24:MI')AS date
     55FROM postcodes
     56WHERE NOT deleted
     57ORDER BY created_at DESC LIMIT ?
     58HERE
     59
     60    my $sth = $dbh->prepare($sql);
     61    $sth->execute($num);
     62    return $sth->fetchall_arrayref({});
    4863}
    4964
     
    6378    my $allStats = _getAllStats($dbh);
    6479    my $dateStats = _getDateStats($dbh);
     80    my $lastPostcodes = _getLastPostcodes($dbh, 5);
    6581
    6682    my $vars = {
    6783        allstats => $allStats,
    68         datestats => $dateStats
     84        datestats => $dateStats,
     85        lastpostcodes => $lastPostcodes
    6986    };
    7087   
  • trunk/npemap.org.uk/templates/home_stats.tt

    r230 r235  
    33<li>Outward parts collected: [% allstats.us_out %]</li>
    44</ul>
     5
     6<h3>Recent submissions:</h3>
     7
     8<ul>
     9[% FOREACH postcode = lastpostcodes %]
     10<li><a href="tiles/map.html#[% postcode.easting div 1000 %],[% postcode.northing div 1000 %],1">[% postcode.outward %] [% postcode.inward %]</a> ([% postcode.easting %], [% postcode.northing %]) [[% postcode.date %]]</li>
     11[% END %]
     12</ul>
Note: See TracChangeset for help on using the changeset viewer.