pricecharts

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

commit 975f24a9d48c1b1797ac332be14bf116a8cb5ae1
parent 82b8589fe7e3ff7468b9c3efc9c54b896d845192
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Sun, 15 Mar 2015 18:02:56 -0600

gen_index: add some info about new products

Diffstat:
Mgen_index | 10+++++-----
Mhtml/index.tt2 | 11++++++++++-
2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/gen_index b/gen_index @@ -18,8 +18,7 @@ $| = 1 if ($args{v}); my $cfg = get_config(); my $dbh = get_dbh($cfg->{"general"}); -my $http_cfg = $cfg->{"http"}; -my $work_dir = $http_cfg->{"chroot"} . $http_cfg->{"htdocs"}; +my $work_dir = $cfg->{"http"}{"chroot"} . $cfg->{"http"}{"htdocs"}; print "info: work dir: $work_dir\n" if ($args{v}); my $config = { @@ -41,15 +40,16 @@ $query = "select count(distinct vendor) from prices"; my ($v) = $dbh->selectrow_array($query); my $time = time - (7 * 24 * 60 * 60); -$query = "select count(part_num) from products where first_seen > ?"; -my ($n) = $dbh->selectrow_array($query, undef, $time); +$query = "select description, part_num from products where first_seen > $time"; +my $new_products = $dbh->selectall_arrayref($query); +my $n = @$new_products; print "info: $m manufacturers, $p products ($n new), $v vendors\n" if ($args{v}); my $vars = { num_vendors => $v, num_manufacturers => $m, num_products => $p, - new_products => $n + new_products => $new_products }; $template->process("index.tt2", $vars, "index.html") diff --git a/html/index.tt2 b/html/index.tt2 @@ -2,7 +2,7 @@ <div class="column"> <h1>Welcome</h1> - <p> Welcome to <em>Price</em><b>Chart</b>, a price comparison + <p> Welcome to <em>Price</em>Chart, a price comparison service for consumer electronics. Currently <b>[% num_products %]</b> products from <b>[% num_manufacturers %]</b> manufacturers are tracked across @@ -34,4 +34,13 @@ different retailers for the same product is often hundreds of dollars if not more. </p> </div> + + <div class="column"> + <h1>New Products</h1> + <ul> + [% FOREACH new_product IN new_products %] + <li>[% new_product.0 %] [% new_product.1 %] + [% END %] + </ul> + </div> [% END %]