| 1 | package App::teai::Dash::Sessions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use App::teai::Err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use App::teai::Bus (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use App::teai::Dash (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use App::teai::Lead (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use App::teai::Presence (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use App::teai::Session (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use App::teai::Wire (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | BEGIN { *esc = \&App::teai::Dash::esc } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub _err ($code, $msg) { eval { App::teai::Err::fail($code, $msg) }; $@ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_err: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub nav ($class) { ([ 'Sessions', '/' ]) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nav: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub routes ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
routes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | [ GET => qr{\A/\z}, \&_list ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | [ POST => qr{\A/session/rm\z}, \&_rm ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub _list ($c) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $bus = $c->bus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my %got; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $left = 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $then = sub { _render($c, \%got) unless --$left }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $bus->sessions($c->cb(sub ($list, $e = undef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | return $c->fail($e) if defined $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $got{sessions} = $list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $then->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | })); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | App::teai::Presence::list($bus, $c->cb(sub ($p, $e = undef) { @got{qw(peers peers_err)} = ($p, $e); $then->() })); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | App::teai::Lead::leases($bus, $c->cb(sub ($l, $e = undef) { @got{qw(leases leases_err)} = ($l, $e); $then->() })); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub _cells (@values) { join '', map { '<td' . ($_->[0] ? qq{ class="$_->[0]"} : '') . '>' . $_->[1] . '</td>' } @values } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cells: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub _render ($c, $got) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_render: not called CC=34 SCAR=70.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my @notes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $peers = $got->{peers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if (defined(my $e = $got->{peers_err})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | push @notes, App::teai::Bus::no_bucket($e) ? 'the hub has no teai_peers bucket: run teai init' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | : 'cannot read presence (' . App::teai::Bus::_text($e) . ')'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $leases = $got->{leases} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$got->{"leases"} // {}
MC/DC0%0/1
$got->{"leases"} // {}
$got->{"leases"}
Truth table0%0/2
A
A= $got->{"leases"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | push @notes, 'cannot read the leads (' . App::teai::Bus::_text($got->{leases_err}) . ')' if defined $got->{leases_err}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my %inbox = map { ($_->{session} => $_) } @{ $got->{sessions} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my %led; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | push @{ $led{ $leases->{$_}{session} } }, $_ for sort keys %$leases; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my %ids = (%inbox, map { $peers->{$_}{live} && @{ $peers->{$_}{live} } ? ($_ => 1) : () } keys %{ $peers // {} }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$peers->{$_}{"live"} and @{$peers->{$_}{"live"};}
$peers // {}
MC/DC0%0/2
$peers->{$_}{"live"} and @{$peers->{$_}{"live"};}
$peers->{$_}{"live"}
@{$peers->{$_}{"live"};}
MC/DC0%0/1
$peers // {}
$peers
Truth table0%0/3
A and B
A= $peers->{$_}{"live"}B= @{$peers->{$_}{"live"};}
Truth table0%0/2
A
A= $peers
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $live = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $rows = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | for my $id (sort keys %ids) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $s = $inbox{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $p = $peers ? $peers->{$id} // { live => [] } : { live => undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$peers->{$id} // {"live", []}
MC/DC0%0/1
$peers->{$id} // {"live", []}
$peers->{$id}
Truth table0%0/2
A
A= $peers->{$id}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $kinds = $p->{live}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $live++ if $kinds && @$kinds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$kinds and @$kinds
MC/DC0%0/2
$kinds and @$kinds
$kinds
@$kinds
Truth table0%0/3
A and B
A= $kindsB= @$kinds
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | my %a = map { ($_ => $p->{$_} // ($s // {})->{$_}) } qw(agent project role); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$p->{$_} // +($s // {})->{$_}
$s // {}
MC/DC0%0/2
$p->{$_} // +($s // {})->{$_}
$p->{$_}
$s
Truth table0%0/3
A // B
A= $p->{$_}B= $s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my $action = $id eq $c->operator ? '(this dashboard)' : $s ? $c->form('/session/rm', { id => $id }, '', 'remove') : 'no inbox'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | $rows .= '<tr id="s-' . esc($id) . '">' . _cells( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | [ session => esc($id) ], [ agent => esc($a{agent}) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | [ live => !$kinds ? '?' : @$kinds ? esc(join ',', @$kinds) : 'no' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | [ hosts => esc(join ', ', @{ $p->{hosts} // [] }) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/8
$p->{"hosts"} // []
$a{"role"} // "-"
$a{"project"} // "-"
$s->{"last_delivery"} // "never"
MC/DC0%0/1
$p->{"hosts"} // []
$p->{"hosts"}
MC/DC0%0/1
$a{"role"} // "-"
$a{"role"}
MC/DC0%0/1
$a{"project"} // "-"
$a{"project"}
MC/DC0%0/1
$s->{"last_delivery"} // "never"
$s->{"last_delivery"}
Truth table0%0/2
A
A= $p->{"hosts"}
Truth table0%0/2
A
A= $a{"role"}
Truth table0%0/2
A
A= $a{"project"}
Truth table0%0/2
A
A= $s->{"last_delivery"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | [ role => esc($a{role} // '-') ], [ project => esc($a{project} // '-') ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | [ pending => $s ? esc($s->{pending}) : '-' ], [ held => $s ? esc($s->{held}) : '-' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | [ last => $s ? esc($s->{last_delivery} // 'never') : '-' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | [ lead => esc(join ', ', @{ $led{$id} // [] }) ], [ '', $action ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
$led{$id} // []
MC/DC0%0/1
$led{$id} // []
$led{$id}
Truth table0%0/2
A
A= $led{$id}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ) . "</tr>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | my $lead_rows = join '', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $l = $leases->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | my $on = $peers && $peers->{ $l->{session} } && @{ $peers->{ $l->{session} }{live} // [] } ? 'yes' : 'no'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
$peers and $$peers{$l->{"session"}} and @{$$peers{$l->{"session"}}{"live"} // [];}
$peers and $$peers{$l->{"session"}}
$$peers{$l->{"session"}}{"live"} // []
MC/DC0%0/3
$peers and $$peers{$l->{"session"}} and @{$$peers{$l->{"session"}}{"live"} // [];}
$peers
$$peers{$l->{"session"}}
@{$$peers{$l->{"session"}}{"live"} // [];}
MC/DC0%0/1
$$peers{$l->{"session"}}{"live"} // []
$$peers{$l->{"session"}}{"live"}
Truth table0%0/4
A and B and C
A= $peersB= $$peers{$l->{"session"}}C= @{$$peers{$l->{"session"}}{"live"} // [];}
Truth table0%0/2
A
A= $$peers{$l->{"session"}}{"live"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | '<tr id="lead-' . esc($_) . '">' . _cells([ '', esc($_) ], [ '', esc($l->{session}) ], [ '', esc($l->{epoch}) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | [ '', esc($l->{since} // '-') ], [ '', $on ]) . "</tr>\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$l->{"since"} // "-"
MC/DC0%0/1
$l->{"since"} // "-"
$l->{"since"}
Truth table0%0/2
A
A= $l->{"since"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } sort keys %$leases; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | my $html = '<p class="counts">' . esc(scalar(keys %ids) . ' sessions, ' . $live . ' live, ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | . scalar(keys %$leases) . ' leads') . "</p>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | . join('', map { '<p class="note">' . esc($_) . "</p>\n" } @notes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | . qq{<div class="scroll"><table><thead><tr><th>session</th><th>agent</th><th>live</th><th>hosts</th><th>role</th>} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | . qq{<th>project</th><th>pending</th><th>held</th><th>last delivery</th><th>lead of</th><th></th></tr></thead>\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | . "<tbody>\n$rows</tbody></table></div>\n<h2>Leads</h2>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | . ($lead_rows ? qq{<div class="scroll"><table><thead><tr><th>project</th><th>lead</th><th>epoch</th><th>since</th>} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | . qq{<th>live</th></tr></thead>\n<tbody>\n$lead_rows</tbody></table></div>\n} : "<p>no project has a lead</p>\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $c->page(200, 'Sessions', $html, watch => 'presence'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub _force_form ($c, $id, $label = "remove $id although it is in use") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_force_form: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return $c->form('/session/rm', { id => $id, force => 1 }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | '<label><input type="checkbox" name="sure" value="1">' . esc($label) . '</label>', 'remove with force'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub _rm ($c) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rm: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my $id = $c->param('id') // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$c->param("id") // ""
MC/DC0%0/1
$c->param("id") // ""
$c->param("id")
Truth table0%0/2
A
A= $c->param("id")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | return $c->fail(_err(2, "invalid id '$id'")) unless App::teai::Wire::valid_id($id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | return $c->fail(_err(2, "$id is the operator session of this dashboard")) if $id eq $c->operator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my $force = ($c->param('force') // '') eq '1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$c->param("force") // ""
MC/DC0%0/1
$c->param("force") // ""
$c->param("force")
Truth table0%0/2
A
A= $c->param("force")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($force && ($c->param('sure') // '') ne '1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$force and ($c->param("sure") // "") ne 1
$c->param("sure") // ""
MC/DC0%0/2
$force and ($c->param("sure") // "") ne 1
$force
$c->param("sure")
Truth table0%0/3
A and B
A= $forceB= $c->param("sure")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return $c->page(400, 'Remove a session', '<p>' . esc("Confirm that $id is to be removed although it may be in use.") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | . "</p>\n" . _force_form($c, $id)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $bus = $c->bus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my $go = sub ($peers) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | App::teai::Session::remove($bus, $id, by => $c->operator, force => $force, peers => $peers, $c->cb(sub ($r, $e = undef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return $c->fail_result($e) if defined $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return $c->fail(_err(1, "no session $id")) if $r->{missing}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ($r->{busy}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return $c->page(400, 'Remove a session', '<p class="error">' . esc("session $id is in use (@{ $r->{busy} })") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | . "</p>\n" . _force_form($c, $id)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $html = '<p>' . esc("removed $id") . "</p>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | $html .= '<p class="note">' . esc("left the runtime files of $id: $r->{left}") . "</p>\n" if defined $r->{left}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | $html .= '<p class="note">' . esc("left the leases of $id: $r->{leases}") . "</p>\n" if defined $r->{leases}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $c->result(200, 'Remove a session', $html . qq{<p><a href="/">sessions</a></p>}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | })); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | return $go->(undef) if $force; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | App::teai::Session::peers($bus, [$id], $c->cb(sub ($peers, $e = undef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return $go->($peers) unless defined $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my $why = ref $e && $e->{reason} ? _err(3, $e->{reason}) : $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $e and $e->{"reason"}
MC/DC0%0/2
ref $e and $e->{"reason"}
ref $e
$e->{"reason"}
Truth table0%0/3
A and B
A= ref $eB= $e->{"reason"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $c->fail($why, _force_form($c, $id, "remove $id without the live check")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | })); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||