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=59a856631b5a1cfdc042664a3d7c67815453c61f;hp=ce319facae713bb9e32edddf86a1509d979b4772;hb=a0835ba69f333931705bf31f39b82339e7c5b16a;hpb=1457a9e8d2e5ddda2b05b658e69df1b80a07320d diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index ce319fa..59a8566 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 @@ -546,7 +549,7 @@ if ($qa->{'debug'}) { my ($varname, $qty) = m/^ \s* \d+ \s+ (\w+) \s+ (?: [A-Z*]+ \s+ )? - ([0-9.]+) \s + ([+-e0-9.]+) \s /x or die "$cplex \n==\n $glpsol_out $_ ?"; if ($varname =~ m/^f(\d+)s(\d+)_/) { my ($ix,$orgix) = ($1,$2); @@ -635,14 +638,18 @@ Generated by YARRG at <% % % foreach my $i (0..$#islandids) { <% $tbody->(1) %> - + % $iquery->execute($islandids[$i]); % my ($islandname) = $iquery->fetchrow_array(); % if (!$i) { + Start at <% $islandname |h %> +[what are these codes?] + % } else { % my $this_dist= $distance->($islandids[$i-1],$islandids[$i]); % $total_dist += $this_dist; + <%perl> my $total_value= 0; foreach my $sf (@subflows) { @@ -659,7 +666,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 +680,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 +692,33 @@ Generated by YARRG at <% dstArbitrage => 0, } unless $$todo; $$todo->{'commodname'}= $f->{'commodname'}; + $$todo->{'posinclass'}= ''; + my $incl= $f->{'posinclass'}; + + my $findclass= $dbh->prepare(<execute($f->{'commodclassid'}); + my $classinfo= $findclass->fetchrow_hashref(); + if ($classinfo) { + my $clname= $classinfo->{'commodclass'}; + my $desc= encode_entities(sprintf "%s is under %s", + $f->{'commodname'}, $clname); + my $abbrev= substr($clname,0,1); + if ($incl) { + my $maxpic= $classinfo->{'maxposinclass'}; + $desc.= (sprintf ", commodity %d of %d", + $incl, $maxpic); + if ($classinfo->{'maxposinclass'} >= 8) { + my @tmbs= qw(0 1 2 3 4 5 6 7 8 9); + my $tmbi= ($incl+0.5)*$#tmbs/$maxpic; + $abbrev.= " ".$tmbs[$tmbi]." "; + } + } + $$todo->{'posinclass'}= + "
" + .$abbrev."
"; + } $$todo->{'stallname'}= $stallname; $$todo->{Price}= $price; $$todo->{Timestamp}= $f->{"${od}_timestamp"}; @@ -715,7 +750,7 @@ Generated by YARRG at <% -<% $xinfo %> +<% $xinfo %> <% $totaldesc %> <% $totalwas |h %> total <%perl> @@ -746,6 +781,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 +828,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"