X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-live.git;a=blobdiff_plain;f=yarrg%2Fweb%2Froutetrade;h=41340201bfc8f4d7ab99d2e87a65046d6178b784;hp=b198b9b3867ab7cff6ca4fb2150f2b33d037c921;hb=4ee718187692e362a0e274020a0ad61701f1b2de;hpb=5f3c445b5b9eda482c8098c115a9b5282e55f001 diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index b198b9b..4134020 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -140,6 +140,9 @@ my $stmt= " commods.commodid commodid, commods.unitmass unitmass, commods.unitvolume unitvolume, + commods.ordval ordval, + commods.posinclass posinclass, + commods.commodclassid commodclassid, dist dist, buy.price - sell.price unitprofit FROM commods @@ -635,7 +638,7 @@ Generated by YARRG at <% % % foreach my $i (0..$#islandids) { <% $tbody->(1) %> - + % $iquery->execute($islandids[$i]); % my ($islandname) = $iquery->fetchrow_array(); % if (!$i) { @@ -659,7 +662,7 @@ Generated by YARRG at <% <%perl> my $age_reported= 0; my %flowlists; - #print "" if $qa->{'debug'}; + #print "" if $qa->{'debug'}; foreach my $od (qw(org dst)) { #print " [[ i $i od $od " if $qa->{'debug'}; foreach my $sf (@subflows) { @@ -673,6 +676,7 @@ Generated by YARRG at <% my $price= $f->{"${od}_price"}; my $stallname= $f->{"${od}_stallname"}; my $todo= \$flowlists{$od}{ + (sprintf "%010d", $f->{'ordval'}), $f->{'commodname'}, (sprintf "%07d", ($od eq 'dst' ? 9999999-$price : $price)), @@ -684,6 +688,34 @@ Generated by YARRG at <% dstArbitrage => 0, } unless $$todo; $$todo->{'commodname'}= $f->{'commodname'}; + $$todo->{'posinclass'}= ''; + if ($f->{'posinclass'}) { + my $findclass= $dbh->prepare(<execute($f->{'commodclassid'}); + my $classinfo= $findclass->fetchrow_hashref(); + if ($classinfo->{'maxposinclass'} >= 8) { + my $maxpic= $classinfo->{'maxposinclass'}; + my $inpic= $f->{'posinclass'}; + my @tmbs= qw(TT T M B BB); + my @tmbds= ( 'in Top fifth of list', + 'in 2nd fifth of the list', + 'in Middle fifth of the list', + 'in 2nd-bottom fifth of list', + 'in Bottom fifth of the list'); + my $tmbi= ($inpic+0.5)*$#tmbs/$maxpic; + my $desc= (sprintf "%s is under %s,". + " commodity %d of %d;". + " i.e. %s or %s", + $f->{'commodname'}, + $classinfo->{'commodclass'}, + $inpic, $maxpic, + $tmbs[$tmbi], $tmbds[$tmbi]); + $$todo->{'posinclass'}= + "
$tmbs[$tmbi]
"; + } + } $$todo->{'stallname'}= $stallname; $$todo->{Price}= $price; $$todo->{Timestamp}= $f->{"${od}_timestamp"}; @@ -715,7 +747,7 @@ Generated by YARRG at <% -<% $xinfo %> +<% $xinfo %> <% $totaldesc %> <% $totalwas |h %> total <%perl> @@ -746,6 +778,7 @@ Generated by YARRG at <% % tr_datarow($m,$dline); <<% $td %>><% $collectdeliver %> <<% $td %>><% $t->{'commodname'} |h %> +<<% $td %>><% $t->{'posinclass'} %> % % my @stalls= sort keys %{ $t->{Stalls} }; % my $pstall= sub { @@ -792,7 +825,7 @@ Generated by YARRG at <% } <% $tbody->(1) %> -Total distance: <% $total_dist %> leagues. +Total distance: <% $total_dist %> leagues. Overall net cash flow <% $total_total < 0 ? -$total_total." loss" : $total_total." gain"