Bracket

 view release on metacpan or  search on metacpan

lib/Bracket/Controller/Admin.pm  view on Meta::CPAN

    # Restrict controller to admin role
    my @user_roles = $c->user->roles;

    if (!$c->stash->{is_admin}) {
        $c->go('/error_404');
        return 0;
    }
    else { return 1; }
}

sub update_player_points : Global {
    my ($self, $c) = @_;

    $c->stash->{template} = 'player/all_home.tt';
    my @players = $c->model('DBIC::Player')->all;

    # Get player scores
    foreach my $player (@players) {

        # Avoid non active players
        next if $player->active == 0;

lib/Bracket/Controller/Admin.pm  view on Meta::CPAN

}

# Quality Assurance to check that lower seeds are marked correctly.
sub qa : Global {
    my ($self, $c) = @_;
    my @played_games = $c->model('DBIC::Pick')->search({ player => 1 }, { order_by => 'game' });
    $c->stash->{played_games} = \@played_games;
    $c->stash->{template}     = 'admin/lower_seeds.tt';
}

sub update_points : Global {
    my ($self, $c) = @_;
    my @points = $c->model('DBIC')->update_points;
    $c->flash->{status_msg} = 'Scores Updated';
    $c->response->redirect($c->uri_for($c->controller('Player')->action_for('all')));
    return;
}

=head2 round_out

Mark the round teams go out.

lib/Bracket/Form/Password/ResetEmail.pm  view on Meta::CPAN

	  ->find( { email => $self->field('email')->value } );
	if ( !$is_valid ) {
		$self->field('email')->add_error('Email not on file');
	}
	
	return;
}

# Turn off update_model 

sub update_model {}

no HTML::FormHandler::Moose;
__PACKAGE__->meta->make_immutable;
1

lib/Bracket/Model/DBIC.pm  view on Meta::CPAN

=head2 update_points

SQL update of points that is way faster than player_points action in Admin.
DRAWBACK: only tested on MySQL, may be MySQL specfic update.
SOLUTION: Find DBIC way of doing it?  Use sub-query.

Note: sqlite3 does not like the syntax on this update

=cut

sub update_points {
    my $self    = shift;
    my $storage = $self->schema->storage;
    return $storage->dbh_do(
        sub {
            my $self = shift;
            my $dbh  = shift;
            my $sth  = $dbh->prepare('delete from region_score;');
            $sth->execute;
            $sth = $dbh->prepare('
                insert into region_score



( run in 0.328 second using v1.01-cache-2.11-cpan-b61123c0432 )