Simplify and fix get_participants_list

master
Daniel Berteaud 10 years ago
parent 372e7add34
commit 84cf94b8b5
  1. 13
      vroom.pl

@ -335,7 +335,7 @@ helper remove_participant_from_room => sub {
}; };
# Get a list of participants of a room # Get a list of participants of a room
helper get_participant_list => sub { helper get_participants_list => sub {
my $self = shift; my $self = shift;
my ($name) = @_; my ($name) = @_;
my $room = $self->get_room_by_name($name); my $room = $self->get_room_by_name($name);
@ -348,16 +348,13 @@ helper get_participant_list => sub {
WHERE `room_id`=?'); WHERE `room_id`=?');
}; };
if ($@){ if ($@){
return {msg => $@}; return 0;
} }
$sth->execute($room->{id}); $sth->execute($room->{id});
if ($sth->err){ if ($sth->err){
return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; return 0;
} }
return { return $sth->fetchall_hashref('room_id')->{$room->{id}};
ok => 1,
data => $sth->fetchall_hashref('room_id')->{$room->{id}}
};
}; };
# Set the role of a peer # Set the role of a peer
@ -1012,7 +1009,7 @@ get '/admin/(:room)' => sub {
room => $room room => $room
); );
} }
my $num = scalar keys %{$self->get_participants_list($room)->{data}}; my $num = scalar keys %{$self->get_participants_list($room)};
$self->stash( $self->stash(
room => $room, room => $room,
participants => $num participants => $num

Loading…
Cancel
Save