========== TODO ==========
16:36 <ceb> alpha,byrne,papaya,turtle,jorvik,luthien is my example
-16:46 <ceb> Also trading plan not functional but I guess you know that :-)
-
use POST for update. Hrrm.
LATER OR NOT AT ALL
@archipelagoes
$qa
</%args>
+<&| script &>
+ da_pageload= Date.now();
+</&script>
+
<%perl>
+my $now= time;
my $loss_per_league= 1e-7;
my @flow_conds;
$addcols->({ Text => 1 }, qw(commodname));
$addcols->({ DoReverse => 1 },
qw( org_price org_qty dst_price dst_qty
- Margin unitprofit MaxQty
+ ));
+$addcols->({ DoReverse => 1, SortColKey => 'MarginSortKey' },
+ qw( Margin
+ ));
+$addcols->({ DoReverse => 1 },
+ qw( unitprofit MaxQty
MaxCapital MaxProfit
));
$f->{MaxProfit}= $f->{MaxQty} * $f->{'unitprofit'};
$f->{MaxCapital}= $f->{MaxQty} * $f->{'org_price'};
+ $f->{MarginSortKey}= sprintf "%d",
+ $f->{'dst_price'} * 10000 / $f->{'org_price'};
$f->{Margin}= sprintf "%3.1f%%",
$f->{'dst_price'} * 100.0 / $f->{'org_price'} - 100.0;
% my $v= $flow->{$col->{Name}};
% $col->{Total} += $v if defined $col->{Total};
% $v='' if !$col->{Text} && !$v;
-% $ts_sortkeys{$ci}{$rowid}= $v;
+% my $sortkey= $col->{SortColKey} ?
+% $flow->{$col->{SortColKey}} : $v;
+% $ts_sortkeys{$ci}{$rowid}= $sortkey;
<td <% $col->{Text} ? '' : 'align=right' %>><% $v |h %>
% }
% }
%
% my $iquery= $dbh->prepare('SELECT islandname FROM islands
% WHERE islandid = ?');
+% my %da_ages;
%
<h1>Voyage trading plan</h1>
<table>
% foreach my $i (0..$#islandids) {
-<tr><td colspan=4><strong>
+<tr><td colspan=<% 2+!!$qa->{ShowStalls} %>><strong>
% $iquery->execute($islandids[$i]);
% my ($islandname) = $iquery->fetchrow_array();
% if (!$i) {
Sail to <% $islandname |h %>
% }
</strong>
+% my $age_reported= 0;
% foreach my $od (qw(dst org)) {
% my $sign= $od eq 'dst' ? -1 : +1;
% my %todo;
% $$todo= { } unless $$todo;
% $$todo->{'commodname'}= $f->{'commodname'};
% $$todo->{'stallname'}= $stallname;
-% $$todo->{Price} += $price;
+% $$todo->{Price}= $price;
+% $$todo->{Timestamp}= $f->{"${od}_timestamp"};
% $$todo->{Qty} += $f->{OptQty};
-% $$todo->{Total} = $$todo->{Price} * $$todo->{Qty};
-% $$todo->{Timestamp} = $f->{"${od}_timestamp"};
+% $$todo->{Total}= $$todo->{Price} * $$todo->{Qty};
+% }
+% if (%todo && !$age_reported++) {
+<td colspan=2>
+% my $age= $now - (values %todo)[0]->{Timestamp};
+% my $cellid= "da_${i}";
+% $da_ages{$cellid}= $age;
+(Data age: <span id="<% $cellid %>"><% prettyprint_age($age) %></span>)
% }
% my $total= 0;
% my $dline= 0;
% $dline ^= 1;
% }
% if (%todo) {
-<tr><td>
-<td colspan=<% 2+!!$qa->{ShowStalls} %>>
-<% (values %todo)[0]->{Timestamp} %>
+<tr>
+<td colspan=<% 3+!!$qa->{ShowStalls} %>>
<td align=right>
% if ($od eq 'org') {
Outlay
% }
% }
</table>
+<& query_age:dataages, id2age => \%da_ages &>
%
% } # ========== TRADING PLAN ==========