pricecharts

track prices of consumer electronics
Log | Files | Refs | README

commit 58556c624637d15cba50a38e7ec4f64ed12ad871
parent 9f47df721cda45367f0c43a9b047ea2f1b0793ce
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Wed, 25 Mar 2015 01:12:33 -0600

gen_static: add recently updated list to index

Diffstat:
Mgen_static | 11+++++++----
Mtt/index.tt | 17+++++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/gen_static b/gen_static @@ -132,15 +132,18 @@ for my $part_num (keys %$products) { } # get a list of products added within the last week -my $time = time - (7 * 24 * 60 * 60); -$sql = "select manufacturer, part_num from products where first_seen > $time"; -my $news = $dbh->selectall_arrayref($sql); +$sql = "select manufacturer, part_num from products where first_seen > ?"; +my $news = $dbh->selectall_arrayref($sql, undef, time - (7 * 24 * 60 * 60)); + +$sql = "select manufacturer, part_num from products where last_seen > ?"; +my $upds = $dbh->selectall_arrayref($sql, undef, time - (2 * 60 * 60)); # # index.html # $vars = { - nret => $v, nmanuf => $m, nprod => $p, nnew => scalar @$news, news => $news, + nret => $v, nmanuf => $m, nprod => $p, nnew => scalar @$news, + news => $news, nupd => scalar @$upds, upds => $upds }; print "info: gen index.html\n"; $template->process("index.tt", $vars, "index.html") diff --git a/tt/index.tt b/tt/index.tt @@ -53,4 +53,21 @@ [% END %] </ul> </div> + + <div class="column"> + <h1>Recently Updated ([% nupd %])</h1> + <ul> + [% FOREACH upd IN upds %] + [% PERL %] + my $part_num = $stash->get("upd.1"); + $stash->set("part_lc", lc($part_num)); + my $manufacturer = $stash->get("upd.0"); + $stash->set("manuf_lc", lc($manufacturer)); + [% END %] + <li><img class="logo_small" alt="[% upd.0 %]" + src="/logo/[% manuf_lc %].svg"></img> + <a href="/products/[% part_lc %].html">[% upd.1 %]</a> + [% END %] + </ul> + </div> [% END %]