X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fquery_offers;h=779d80407dc767857e2a74fd389e07432a6b0f96;hp=b9befe2c60ce3ed0016a6a37683737686a6e4d19;hb=59393edc418d7062f6fb074a90d3b8e810c43772;hpb=d343fff49b802614be47d21b569f43b7d42d4511 diff --git a/yarrg/web/query_offers b/yarrg/web/query_offers index b9befe2..779d804 100644 --- a/yarrg/web/query_offers +++ b/yarrg/web/query_offers @@ -54,6 +54,7 @@ my ($commodname,$cmid); my $qa= \%ARGS; +

Prices for commodity at location(s)

% $prselector->('BuySell'); @@ -79,23 +80,27 @@ my $qa= \%ARGS; <& "lookup:formhidden", ours => $ours &> +
+
%#========== results ========== <%perl> $emsgokorprint->($emsg) or $cmid=undef; -return unless defined $cmid and @islandids; +print("
"), return + unless defined $cmid and @islandids; foreach my $wf (@warningfs) { $wf->(); } +if ($qa->{'debug'}) {
-NOT YET IMPLEMENTED
 bs= <% $qa->{BuySell} %>
 cmdid= <% $cmid %>
 islandids= <% join ',', map { defined($_) ? $_ : 'U' } @islandids %>
 
<%perl> +} my $locdesc; if (@islandids>1) { @@ -109,6 +114,8 @@ if (@islandids>1) { $locdesc= ' in '.$archipelagoes[0]; } +my $now= time; + my @conds; my @condvals; push @condvals, $cmid; @@ -124,13 +131,18 @@ foreach my $ix (0..$#islandids) { } } foreach my $bs (split /_/, $qa->{BuySell}) { + my %da_ages; + my %ts_sortkeys; + die unless grep { $bs eq $_ } qw(buy sell); my $ascdesc= $bs eq 'buy' ? 'DESC' : 'ASC';

Offers to <% uc $bs |h %> <% $commodname |h %> <% $locdesc %>

<%perl> my $stmt= " - SELECT archipelago, islandname, stallname, price, qty, timestamp + SELECT archipelago, islandname, + stallname, price, qty, timestamp, + offers.stallid FROM $bs AS offers JOIN islands ON offers.islandid==islands.islandid JOIN uploads ON offers.islandid==uploads.islandid @@ -151,11 +163,67 @@ foreach my $bs (split /_/, $qa->{BuySell}) { <%perl> } + my $row; my $sth= $dbh->prepare($stmt); $sth->execute(@condvals); + my $rowix= 0; - <& dumptable, sth => $sth &> +% while ($row= $sth->fetchrow_arrayref) { +% if (!$rowix) { + ++++ + +% } +% my $rowid= ${bs}.$row->[6]; +% my $tscellid= "c$rowid"; +% my $age= $now - $row->[5]; +% $da_ages{$rowid}= $age; +% $row->[5]= + class="<% 'datarow'.($rowix & 1) %>" > +% foreach my $ci (0..4) { +% my $val= $row->[$ci]; +% $ts_sortkeys{$ci}{$rowid}= $val; + +% $rowix++; +% } +% if ($rowix) { +
Archipelago +Island +Stall or Shoppe +Price +Quantity +Data age +
= 3 ? 'align=right' : '' %> ><% $val |h %> +% } +<% prettyprint_age($age) %> +
+ +<&| tabsort, table => "${bs}_table", rowclass => 'datarow', cols => [ + {}, {}, {}, + { Numeric => 1, DoReverse => 1 }, + { Numeric => 1, DoReverse => 1 }, + { Numeric => 1, DoReverse => 1, SortKey => "${bs}_ages[rowid]" }], + sortkeys => "${bs}_sortkeys" + &> + <%$bs%>_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>; + <%$bs%>_ages= <% to_json_protecttags(\%da_ages) %>; + +% } else { +No offers. +% } + <%perl> } - + +

+(Please don't use these pages to scrape data out of the YARRG +database. This will be a pain for you to program, slow to run, and +pointlessly overload our server. Instead, see our +information for developers +to find out how to get testing data or a real-time feed.) + +