pricecharts

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

commit a8e95f5c1610e3125625d84a4c90b6965f9e7ea6
parent c56cf834f7b0d6ce5ec470761225a1a1b0585629
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Thu,  2 Apr 2015 18:47:59 -0600

gen_static: generate product type indexes too

Diffstat:
Mgen_static | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)

diff --git a/gen_static b/gen_static @@ -107,6 +107,43 @@ $template->process("link_list.tt", $vars, "retailers.html") || die "template: " . $template->error() . "\n"; # +# product_types/* +# +xmkdir("$work_dir/product_types"); + +$sql = "select distinct type from products"; +my $product_types = $dbh->selectcol_arrayref($sql); + +my $t = scalar @$product_types; +print "info: gen product_types/ ($t types total)\n" if ($args{v}); +for my $type (@$product_types) { + my $type_lc = lc($type); + + $sql = "select manufacturer, part_num from products where type = ?"; + my $products = $dbh->selectall_arrayref($sql, undef, $type); + while (my $i = each (@$products)) { + $products->[$i][2] = get_description($products->[$i][0], $products->[$i][1]); + } + + my $vars = { + name => $type, num => scalar @$products, + products => $products, + }; + + $template->process("chart_list.tt", $vars, "product_types/$type_lc.html") + || die "template: " . $template->error() . "\n"; +} + +# +# product_types.html +# +print "info: gen product_types.html\n" if ($args{v}); + +$vars = { name => "Product_Types", num => $t, links => $product_types }; +$template->process("link_list.tt", $vars, "product_types.html") + || die "template: " . $template->error() . "\n"; + +# # products/* # xmkdir "$work_dir/products";