commit 48635a970953acdd77cfec23548a1eaaa689533f
parent 6fda03d4780b2cbaa5eaa634d036810fac876f8b
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Sat, 21 Mar 2015 15:08:41 -0600
all: use the word retailer instead of vendor
Diffstat:
6 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/PriceChart.pm b/PriceChart.pm
@@ -10,7 +10,7 @@ use Exporter;
sub get_config
{
my $parser = Config::Grammar->new({
- _sections => ["general", "http", "vendors"],
+ _sections => ["general", "http", "retailers"],
general => {
_vars => [
'user_agent',
@@ -29,7 +29,7 @@ sub get_config
"logs",
],
},
- vendors => {
+ retailers => {
_sections => ["/[A-Za-z ]+/"],
"/[A-Za-z ]+/" => {
_vars => [
diff --git a/gen_static b/gen_static
@@ -38,10 +38,10 @@ my $manufacturers_sql = "select distinct manufacturer from products";
my $parts_sql = "select part_num, lower(manufacturer), description from products where manufacturer = ?";
my $m = gen_link_page($manufacturers_sql, $parts_sql, "manufacturers", "Manufacturers");
-# vendors.html, vendors/*
-my $vendor_sql = "select distinct vendor from prices";
+# retailers.html, retailers/*
+my $retailers_sql = "select distinct vendor from prices";
$parts_sql = "select distinct part_num from prices where vendor = ?";
-my $v = gen_link_page($vendor_sql, $parts_sql, "vendors", "Retailers");
+my $v = gen_link_page($retailers_sql, $parts_sql, "retailers", "Retailers");
# products.html, products/*
my $product_sql = "select part_num from products";
@@ -56,7 +56,7 @@ my $new_products = $dbh->selectall_arrayref($sql);
# index.html
my $n = @$new_products;
my $vars = {
- num_vendors => $v,
+ num_retailers => $v,
num_manufacturers => $m,
num_products => $p,
num_new => $n,
@@ -65,7 +65,7 @@ my $vars = {
$template->process("index.tt", $vars, "index.html")
|| die "template: " . $template->error() . "\n";
-print "info: $m manufacturers, $p products ($n new), $v vendors\n" if ($args{v});
+print "info: $m manufacturers, $p products ($n new), $v retailers\n" if ($args{v});
$dbh->disconnect();
# generate a page of links to pages of products
diff --git a/gen_svg b/gen_svg
@@ -36,7 +36,7 @@ my $sql = "select date, price, color from prices where " .
my $point_sth = $dbh->prepare($sql);
$sql = "select distinct vendor from prices where part_num = ?";
-my $vendor_sth = $dbh->prepare($sql);
+my $retailer_sth = $dbh->prepare($sql);
$sql = "select manufacturer, part_num, description from products";
my $parts_sth = $dbh->prepare($sql);
@@ -64,14 +64,14 @@ while (my ($brand, $part_num, $description) = $parts_sth->fetchrow_array()) {
my $svg = SVG->new(viewBox => "0 0 $total_width $total_height");
my ($x_scale, $y_scale) = ($width / $domain, $height / $range);
- # render each vendor as a different series
- $vendor_sth->execute($part_num);
- while (my ($vendor) = $vendor_sth->fetchrow_array()) {
+ # render each retailer as a different series
+ $retailer_sth->execute($part_num);
+ while (my ($retailer) = $retailer_sth->fetchrow_array()) {
my (@xs, @ys);
my $line_color = "#000";
# gather all points in the series
- $point_sth->execute($part_num, $vendor);
+ $point_sth->execute($part_num, $retailer);
while (my ($date, $price, $color) = $point_sth->fetchrow_array) {
# transform and clamp real world coordinates
push @xs, ($date - $x_min) * $x_scale + $left;
@@ -79,7 +79,7 @@ while (my ($brand, $part_num, $description) = $parts_sth->fetchrow_array()) {
# small filled in circles to indicate data points
my $tag = $svg->anchor(
- -href => $cfg->{vendors}{$vendor}{search_url} . $part_num,
+ -href => $cfg->{retailers}{$retailer}{search_url} . $part_num,
target => "new_window"
)->circle(
cx => $xs[-1], cy => $ys[-1],
@@ -99,11 +99,11 @@ while (my ($brand, $part_num, $description) = $parts_sth->fetchrow_array()) {
# polyline sucks, spline would look nicer
my $tag = $svg->anchor(
- -href => $cfg->{vendors}{$vendor}{search_url} . $part_num,
+ -href => $cfg->{retailers}{$retailer}{search_url} . $part_num,
target => "new_window"
);
$tag->polyline(
- %$points, id => $vendor,
+ %$points, id => $retailer,
style => {
"fill-opacity" => 0, fill => "#$line_color",
stroke => "#$line_color", "stroke-width" => 2,
diff --git a/price_scraper b/price_scraper
@@ -66,8 +66,8 @@ my $products_sth = $dbh->prepare($sql);
my $timestamp = strftime("%F %T> ", localtime);
my ($start, @status, $i) = (time, "", -1);
-for my $vendor (sort keys %{$cfg->{"vendors"}}) {
- my %props = %{$cfg->{"vendors"}{$vendor}};
+for my $retailer (sort keys %{$cfg->{retailers}}) {
+ my %props = %{$cfg->{retailers}{$retailer}};
# this could probably be done smarter
my $url = $props{"search_url"};
my $color = $props{"color"};
@@ -75,7 +75,7 @@ for my $vendor (sort keys %{$cfg->{"vendors"}}) {
my $sale_tag = $props{"price_sale"};
my $desc_tag = $props{"title"};
- my $vendor_start = time;
+ my $retailer_start = time;
$status[++$i] = " ";
# for products with short part numbers, also search manufacturer
@@ -86,13 +86,13 @@ for my $vendor (sort keys %{$cfg->{"vendors"}}) {
$search = uri_escape($part_num);
}
- # get a page of search results from a vendor
+ # get a page of search results from a retailer
my $search_results = get_dom($url . $search, $ua, $args{v}, $log);
next unless defined $search_results;
# search search_results for particular html tags that should be prices
- my $price_r = get_valid_price($price_tag, $search_results, $vendor);
- my $price_s = get_valid_price($sale_tag, $search_results, $vendor);
+ my $price_r = get_valid_price($price_tag, $search_results, $retailer);
+ my $price_s = get_valid_price($sale_tag, $search_results, $retailer);
next unless ($price_r || $price_s);
# choose the lowest that exists
@@ -108,20 +108,20 @@ for my $vendor (sort keys %{$cfg->{"vendors"}}) {
$desc =~ s/^\s+//;
$desc =~ s/\s+$//;
if ($desc ne "" && $args{v}) {
- my $desc_s = trunc_line($desc, length($vendor) + 8);
- print "info: $vendor: $desc_s\n";
+ my $desc_s = trunc_line($desc, length($retailer) + 8);
+ print "info: $retailer: $desc_s\n";
}
}
# everything looks good
- $status[$i] = substr($vendor, 0, 1);
+ $status[$i] = substr($retailer, 0, 1);
next if ($args{n});
- $prices_sth->execute($start, $part_num, $vendor, $color,
- $price, time - $vendor_start, $desc);
+ $prices_sth->execute($start, $part_num, $retailer, $color,
+ $price, time - $retailer_start, $desc);
$products_sth->execute($start, $part_num);
- print "info: $vendor: db: inserted \$$price\n" if ($args{v});
+ print "info: $retailer: db: inserted \$$price\n" if ($args{v});
}
printf $log "%s %-10s %-20s [%s] (%i s)\n", $timestamp, $manufacturer,
@@ -138,15 +138,15 @@ sub get_valid_price
{
my $dom_tag = shift || return undef;
my $search_results = shift;
- my $vendor = shift;
+ my $retailer = shift;
# break the search_results page down into individual results
my @search_prices = $search_results->find($dom_tag)->text_array();
my $num_prices = @search_prices;
return undef if ($num_prices == 0);
- print "info: $vendor: $dom_tag: $num_prices elements\n" if ($args{v});
- my $hdr = "$vendor: $dom_tag" . "[0]";
+ print "info: $retailer: $dom_tag: $num_prices elements\n" if ($args{v});
+ my $hdr = "$retailer: $dom_tag" . "[0]";
# do a fuzzy search for digit combinations that look like a price
# XXX: uses the first found price in the page
diff --git a/tt/index.tt b/tt/index.tt
@@ -6,7 +6,7 @@
service for consumer electronics.
Currently <b>[% num_products %]</b> products from
<b>[% num_manufacturers %]</b> manufacturers are tracked across
- <b>[% num_vendors %]</b> retailers.</p>
+ <b>[% num_retailers %]</b> retailers.</p>
<p> To start, try searching for a product or manufacturer in the
search box at the top right. </p>
diff --git a/tt/wrapper.tt b/tt/wrapper.tt
@@ -9,7 +9,7 @@
<body>
<a id="title" href="/"><em>Price</em><b>Chart</b></a>
<a href="/manufacturers.html">Manufacturers</a>
- <a href="/vendors.html">Retailers</a>
+ <a href="/retailers.html">Retailers</a>
<form method="get" action="/search.html">
<fieldset>
<input type="text" name="q" />