… | |
… | |
133 | } |
133 | } |
134 | } |
134 | } |
135 | } |
135 | } |
136 | |
136 | |
137 | sub format_time { |
137 | sub format_time { |
|
|
138 | if ($_[0] < 0) { |
|
|
139 | "--:--:--"; |
|
|
140 | } elsif ($_[0] >= 60*60*24) { |
138 | sprintf "%02dd %02d:%02d:%02d", |
141 | sprintf "%02dd %02d:%02d:%02d", |
139 | int ($_[0] / (60 * 60 * 24)), |
142 | int ($_[0] / (60 * 60 * 24)), |
140 | int ($_[0] / (60 * 60)) % 24, |
143 | int ($_[0] / (60 * 60)) % 24, |
141 | int ($_[0] / 60) % 60, |
144 | int ($_[0] / 60) % 60, |
142 | int ($_[0]) % 60; |
145 | int ($_[0]) % 60; |
|
|
146 | } else { |
|
|
147 | sprintf "%02d:%02d:%02d", |
|
|
148 | int ($_[0] / (60 * 60)) % 24, |
|
|
149 | int ($_[0] / 60) % 60, |
|
|
150 | int ($_[0]) % 60; |
|
|
151 | } |
143 | } |
152 | } |
144 | |
153 | |
145 | sub conn::diridx { |
154 | sub conn::diridx { |
146 | my $self = shift; |
155 | my $self = shift; |
147 | |
156 | |
… | |
… | |
226 | $content .= "<li>$name<br />".(scalar @waiters)." client(s)"; |
235 | $content .= "<li>$name<br />".(scalar @waiters)." client(s)"; |
227 | |
236 | |
228 | $content .= "<p>Waiting time until download starts, estimated:<ul>"; |
237 | $content .= "<p>Waiting time until download starts, estimated:<ul>"; |
229 | for ( |
238 | for ( |
230 | ["by most recently started transfer", $queue->{lastspb}], |
239 | ["by most recently started transfer", $queue->{lastspb}], |
|
|
240 | ["by queue average", $queue->{avgspb}], |
231 | ["by next client in queue", $waiters[0]{spb}], |
241 | ["by next client in queue", $waiters[0]{spb}], |
232 | ) { |
242 | ) { |
233 | my ($by, $spb) = @$_; |
243 | my ($by, $spb) = @$_; |
234 | $content .= "<li>$by<br />"; |
244 | $content .= "<li>$by<br />"; |
235 | if ($spb) { |
245 | if ($spb) { |
… | |
… | |
242 | } |
252 | } |
243 | $content .= "</li>"; |
253 | $content .= "</li>"; |
244 | } |
254 | } |
245 | $content .= "</ul></p>"; |
255 | $content .= "</ul></p>"; |
246 | |
256 | |
|
|
257 | @waiters = grep { $verbose || $_->{coro}{conn}{remote_id} eq $self->{remote_id} } @waiters; |
247 | if ($verbose) { |
258 | if (@waiters) { |
248 | $content .= "<table border='1' width='100%'><tr><th>Remote ID</th><th>CN</th><th>Size</th><th>Waiting</th><th>SPB</th><th>URI</th></tr>"; |
259 | $content .= "<table border='1' width='100%'><tr><th>Remote ID</th><th>CN</th><th>Size</th><th>Waiting</th><th>ETA</th><th>URI</th></tr>"; |
249 | for (@waiters) { |
260 | for (@waiters) { |
250 | my $conn = $_->{coro}{conn}; |
261 | my $conn = $_->{coro}{conn}; |
251 | my $time = format_time ($::NOW - $_->{time}); |
262 | my $time = format_time ($::NOW - $_->{time}); |
|
|
263 | my $eta = format_time ($queue->{avgspb} * $_->{size} - ($::NOW - $_->{time})); |
252 | $content .= "<tr>". |
264 | $content .= "<tr>". |
253 | "<td>$conn->{remote_id}</td>". |
265 | "<td>$conn->{remote_id}</td>". |
254 | "<td>$conn->{country}</td>". |
266 | "<td>$conn->{country}</td>". |
255 | "<td>$_->{size}</td>". |
267 | "<td>$_->{size}</td>". |
256 | "<td>$time</td>". |
268 | "<td>$time</td>". |
257 | "<td>$_->{spb}</td>". |
269 | "<td>$eta</td>". |
258 | "<td>".escape_html($conn->{name})."</td>". |
270 | "<td>".escape_html($conn->{name})."</td>". |
259 | "</tr>"; |
271 | "</tr>"; |
260 | } |
272 | } |
261 | $content .= "</table></li>"; |
273 | $content .= "</table></li>"; |
262 | } |
274 | } |