From 529d79634e714733d47e4cbcd385a727e9fae703 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 20 Aug 2009 00:09:10 +0100 Subject: [PATCH] Reorganise columns --- yarrg/web/query_commod | 47 ++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) 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'} }; % } -- 2.30.2
+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 %>