Purge inactive participants from the database

Fix #74
master
Daniel Berteaud 11 years ago
parent 35475e3638
commit 8b0a0ae6ee
  1. 13
      public/vroom.pl

@ -329,6 +329,15 @@ helper has_joined => sub {
return $ret; return $ret;
}; };
# Purge disconnected participants from the DB
helper delete_participants => sub {
my $self = shift;
$self->app->log->debug('Removing inactive participants from the database');
my $sth = eval { $self->db->prepare("DELETE FROM participants WHERE (`activity_timestamp` < 7200 OR `activity_timestamp` IS NULL);") } || return undef;
$sth->execute() || return undef;
return 1;
};
# Purge unused rooms # Purge unused rooms
helper delete_rooms => sub { helper delete_rooms => sub {
my $self = shift; my $self = shift;
@ -1046,6 +1055,10 @@ post '/action' => sub {
if ((int (rand 100)) <= 10){ if ((int (rand 100)) <= 10){
$self->delete_invitations; $self->delete_invitations;
} }
# And also remove inactive participants
if ((int (rand 100)) <= 10){
$self->delete_participants;
}
if ($res){ if ($res){
$status = 'success'; $status = 'success';
$msg = ''; $msg = '';

Loading…
Cancel
Save