| 1 | package Bb::Collaborate::Ultra::Session::Log; | ||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use Mouse; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use JSON; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | extends 'Bb::Collaborate::Ultra::DAO'; | |||||||||||||||||||
| 6 | 1 | ▶ | use Mouse::Util::TypeConstraints; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use Bb::Collaborate::Ultra::Session::Log::Attendee; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | Bb::Collaborate::Ultra::Session::Log | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | Session logging class. | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | =head1 EXAMPLE | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | my @sessions = Bb::Collaborate::Ultra::Session->get($connection, {contextId => $context_id}); | ||||||||||||||||||||
| 20 | for my $session (@sessions) { | ||||||||||||||||||||
| 21 | print "Session: ". $session->name . "\n"; | ||||||||||||||||||||
| 22 | my @logs = $session->logs({expand => 'attendees' }); | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | for my $log (@logs) { | ||||||||||||||||||||
| 25 | say "\tOpened: " .(scalar localtime $log->opened); | ||||||||||||||||||||
| 26 | for my $attendee (@{$log->attendees}) { | ||||||||||||||||||||
| 27 | my $first_join; | ||||||||||||||||||||
| 28 | my $elapsed = 0; | ||||||||||||||||||||
| 29 | for my $attendance (@{$attendee->attendance}) { | ||||||||||||||||||||
| 30 | my $joined = $attendance->joined; | ||||||||||||||||||||
| 31 | $first_join = $joined | ||||||||||||||||||||
| 32 | if !$first_join || $first_join > $joined; | ||||||||||||||||||||
| 33 | $elapsed += $attendance->left - $joined; | ||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | say sprintf("\tUser %s (%s) joined at %s, stayed %d minutes", $attendee->externalUserId, $attendee->displayName, (scalar localtime $first_join), $elapsed / 60); | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | say "\tClosed: " .(scalar localtime $log->closed); | ||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =head1 METHODS | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | This class supports the `get` method as described in L<https://xx-csa.bbcollab.com/documentation#Attendee-collection>. | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | coerce __PACKAGE__, from 'HashRef' => via { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 48 | 0 | __PACKAGE__->new( $_ ) | |||||||||||||||||||
| 49 | 1 | }; | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | sub _thaw { | ||||||||||||||||||
|
Subroutine
_thaw: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||
| 53 | 0 | my $data = shift; | |||||||||||||||||||
| 54 | 0 | my $thawed = $self->SUPER::_thaw($data, @_); | |||||||||||||||||||
| 55 | 0 | my $attendees = $data->{attendees}; | |||||||||||||||||||
| 56 | 0 | ▶ | $thawed->{attendees} = [ map { Bb::Collaborate::Ultra::Session::Log::Attendee->_thaw($_) } (@$attendees) ] | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | if $attendees; | ||||||||||||||||||||
| 58 | 0 | $thawed; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 1 | __PACKAGE__->resource('instances'); | |||||||||||||||||||
| 62 | 1 | __PACKAGE__->load_schema(<DATA>); | |||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 1 | __PACKAGE__->query_params( | |||||||||||||||||||
| 65 | expand => 'Str', # 'attendees' | ||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 1 | subtype 'ArrayOfAttendees', | |||||||||||||||||||
| 69 | as 'ArrayRef[Bb::Collaborate::Ultra::Session::Log::Attendee]'; | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | coerce 'ArrayOfAttendees', | ||||||||||||||||||||
| 72 | from 'ArrayRef[HashRef]', | ||||||||||||||||||||
| 73 | 0 | ▶ | via { [ map {Bb::Collaborate::Ultra::Session::Log::Attendee->new($_)} (@$_) ] }; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 1 | has 'attendees' => (isa => 'ArrayOfAttendees', is => 'rw', coerce => 1); | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =head2 get_attendees | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | Returns a list of attendees for this session instance; | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | my @all_attendees; | ||||||||||||||||||||
| 82 | my @logs = $session->get_logs; | ||||||||||||||||||||
| 83 | for my $log (@logs) { | ||||||||||||||||||||
| 84 | push @all_attendees, $log->get_attendees; | ||||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | Note: Alternatively, the C<expand => 'attendees'> query parameter may be set in the C<get_logs>. This causes the server to eagerly populate the attendees in each session log. | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | my @all_attendees; | ||||||||||||||||||||
| 90 | my @logs = $session->get_logs({expand => 'attendees' }); | ||||||||||||||||||||
| 91 | for my $log (@logs) { | ||||||||||||||||||||
| 92 | push @all_attendees, @{ $log->attendees }; | ||||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | This reduces the number of calls to the server, and is generally faster. | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 0 | ▶ | sub get_attendees { | ||||||||||||||||||
|
Subroutine
get_attendees: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||
| 101 | 0 | ▶ | my $query = shift || {}; | ||||||||||||||||||
|
Condition0%0/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||
| 102 | 0 | my %opt = @_; | |||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 0 | ▶ | my $connection = $opt{connection} || $self->connection; | ||||||||||||||||||
|
Condition0%0/3
$opt{'connection'} || $self->connection
MC/DC0%0/2
$opt{'connection'} || $self->connection
$opt{'connection'}
$self->connection
Truth table0%0/3
A || B
A= $opt{'connection'}B= $self->connection
| |||||||||||||||||||||
| 105 | 0 | my $path = $self->path.'/attendees'; | |||||||||||||||||||
| 106 | 0 | require Bb::Collaborate::Ultra::Session::Log::Attendee; | |||||||||||||||||||
| 107 | 0 | my @attendees = Bb::Collaborate::Ultra::Session::Log::Attendee->get($connection => $query, path => $path, parent => $self); | |||||||||||||||||||
| 108 | $self->{attendees} = \@attendees | ||||||||||||||||||||
| 109 | 0 | ▶ | if $opt{cache}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | 0 | @attendees; | |||||||||||||||||||
| 112 | } | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | # **NOT DOCUMENTED** in https://xx-csa.bbcollab.com/documentation | ||||||||||||||||||||
| 115 | # schema has been reversed engineered | ||||||||||||||||||||
| 116 | 1 | 1; | |||||||||||||||||||
| 117 | __DATA__ | ||||||||||||||||||||