pricecharts

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

commit a98d590a4dbe7f816e3313d36ef1df6b6305b763
parent 83c9f6af6ef4394d9240a9bc0472870bd6dee376
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Sat,  1 Nov 2014 16:19:46 -0600

gen_svg: don't print invalid products

Diffstat:
Mgen_svg.pl | 11+++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/gen_svg.pl b/gen_svg.pl @@ -41,22 +41,17 @@ $query = "select distinct vendor from prices where part_num = ?"; my $vendor_sth = $dbh->prepare($query); for my $part_num (@$part_nums) { - vprint("$part_num:\n"); - $query = "select distinct date from prices where part_num = ?"; my $dates = $dbh->selectcol_arrayref($query, undef, $part_num); $query = "select distinct price from prices where part_num = ?"; my $prices = $dbh->selectcol_arrayref($query, undef, $part_num); - if (@$dates == 0) { - vprintf("\tno price information, skipping\n"); - next; - } - elsif (@$dates == 1) { - vprintf("\tsingle price point, graphing will explode, skipping\n"); + if (@$dates == 0 || @$dates == 1) { next; } + vprint("$part_num:\n"); + my ($x_min, $x_max) = (min(@$dates), max(@$dates)); my ($y_min, $y_max) = (min(@$prices), max(@$prices));