From: Ian Jackson Date: Wed, 19 Aug 2009 23:09:10 +0000 (+0100) Subject: Reorganise columns X-Git-Tag: 3.4~165 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=commitdiff_plain;h=529d79634e714733d47e4cbcd385a727e9fae703 Reorganise columns --- diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod index 9a7d2bc..a4063c1 100644 --- a/yarrg/web/query_commod +++ b/yarrg/web/query_commod @@ -117,44 +117,55 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { + % $islands->execute($commodid); % my $island; % while ($island= $islands->fetchrow_hashref) { % my $islandid= $island->{'islandid'}; % $offers->execute($commodid, $islandid); -% my ($offer, $best, $median); +% my ($offer, $bestprice, $median, $marginal, @beststalls); % my $tqty= $island->{'tqty'}; % my $cqty= 0; +% my $bestqty= 0; +% my $approxqty= 0; % while ($offer= $offers->fetchrow_hashref) { -% if (!$best) { -% $best= { 'price' => $offer->{'price'} }; -% } -% if ($offer->{'price'} == $best->{'price'}) { -% $best->{'qty'} += $offer->{'qty'}; -% push @{ $best->{'stalls'} }, -% $offer->{'stallname'}; +% my $price= $offer->{'price'}; +% my $qty= $offer->{'qty'}; +% defined $bestprice or $bestprice= $price; +% if ($price == $bestprice) { +% $bestqty += $qty; +% push @beststalls, $offer->{'stallname'}; % } -% $cqty += $offer->{'qty'}; +% $cqty += $qty; % if ($cqty*2 >= $tqty && !defined $median) { -% $median= $offer->{'price'}; +% $median= $price; +% } +% if ($bestprice*9 <= $price*10 and +% $price*10 <= $bestprice*11) { +% $approxqty += $qty; % } % } +% my $nstalls= @beststalls; % $cqty == $tqty or die "$bs $cqty $tqty $commodid $islandid "; -% my $nstalls= @{ $best->{'stalls'} }; % }
+Prices +Quantities available +
Archipelago Island Unique best stall -Best price -Qty at best -Median price -Total qty +Best +Median +At best +Within 10% +Total
<% $island->{'archipelago'} |h %> <% $island->{'islandname'} |h %> - <% $nstalls==1 ? $best->{'stalls'}[0] : "$nstalls offers" |h %> - <% $best->{'price'} %> - <% $best->{'qty'} %> + <% $nstalls==1 ? $beststalls[0] : "$nstalls offers" |h %> + <% $bestprice %> <% $median %> + <% $bestqty %> + <% $approxqty %> <% $tqty %>