1
0
mirror of https://gitlab.com/depesz/explain.depesz.com.git synced 2024-11-24 08:42:27 +02:00

perltidy code

This commit is contained in:
Hubert depesz Lubaczewski 2019-05-14 13:05:34 +02:00
parent 06503d10d9
commit f9e0abffe5
5 changed files with 31 additions and 26 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
log
explain.production.json
.vagrant
*.beforeTidy

View File

@ -19,9 +19,11 @@ sub startup {
# array format
my $use_secret = $config->{ secret } || 'Xwyfe-_d:yGDr+p][Vs7Kk+e3mmP=c_|s7hvExF=b|4r4^gO|';
if ( $self->can( 'secrets' ) ) {
# We're on Mojolicious 4.63 or newer
$self->secrets( [ $use_secret ] );
} else {
}
else {
# We're on old Mojolicious
$self->secret( $use_secret );
}

View File

@ -153,7 +153,7 @@ sub login {
if ( my $user = $self->database->user_login( $username, $password ) ) {
$self->flash( 'message' => 'User logged in.' );
$self->session( 'user' => $username );
$self->session( 'user' => $username );
$self->session( 'admin' => $user->{ 'admin' } );
$self->redirect_to( 'new-explain' );
}
@ -172,9 +172,9 @@ sub new_optimization {
return $self->redirect_to( 'new-explain', status => 404 ) unless $original_plan;
$self->stash->{ 'optimization' } = 1;
$self->stash->{ 'optimization' } = 1;
$self->stash->{ 'original_plan_id' } = $original_plan_id;
$self->stash->{ 'original_title' } = $original_title;
$self->stash->{ 'original_title' } = $original_title;
return $self->render( 'controller/index' );
}
@ -332,7 +332,7 @@ sub show {
# Fetch path of optimizations
$self->stash->{ optimization_path } = $self->database->get_optimization_path( $id );
$self->stash->{ suboptimizations } = $self->database->get_optimizations_for( $id );
$self->stash->{ suboptimizations } = $self->database->get_optimizations_for( $id );
# render will be called automatically
return;
@ -403,15 +403,17 @@ sub info {
next if $module =~ m{^\.?/};
$module =~ s/\.pm$//;
$module =~ s#/#::#g;
push @versions, {
'module' => $module,
push @versions,
{
'module' => $module,
'version' => $module->VERSION,
};
};
}
$self->stash( 'modules' => \@versions );
$self->stash( 'perl' => {
$self->stash(
'perl' => {
'version' => $PERL_VERSION,
'binary' => $Config{'perlpath'} . $Config{'_exe'},
'binary' => $Config{ 'perlpath' } . $Config{ '_exe' },
}
);
@ -419,10 +421,11 @@ sub info {
sub status {
my $self = shift;
if ($self->database->ping()) {
$self->render('text' => 'OK', status => 200);
} else {
$self->render('text' => 'DB FAILED', status => 500);
if ( $self->database->ping() ) {
$self->render( 'text' => 'OK', status => 200 );
}
else {
$self->render( 'text' => 'DB FAILED', status => 500 );
}
}

View File

@ -87,7 +87,7 @@ sub user_login {
my $crypted = crypt( $password, $row[ 0 ] );
return if $crypted ne $row[ 0 ];
return { 'admin' => $row[1] };
return { 'admin' => $row[ 1 ] };
}
sub user_change_password {
@ -262,10 +262,9 @@ sub get_plan {
sub get_optimization_path {
my $self = shift;
my ($plan_id) = @_;
my ( $plan_id ) = @_;
my $rows = $self->dbh->selectall_arrayref(
'
my $rows = $self->dbh->selectall_arrayref( '
WITH RECURSIVE path AS (
SELECT id, title, optimization_for, 0 as level FROM plans WHERE id = ? and not is_deleted
union all
@ -290,9 +289,9 @@ sub get_optimization_path {
}
sub get_optimizations_for {
my $self = shift;
my ($plan_id) = @_;
my $rows = $self->dbh->selectall_arrayref(
my $self = shift;
my ( $plan_id ) = @_;
my $rows = $self->dbh->selectall_arrayref(
'select id, title from plans where optimization_for = ? and not is_deleted',
{ Slice => {} },
$plan_id

View File

@ -21,17 +21,17 @@ sub register {
eval {
my $email = Email::Simple->create(
header => [
To => $self->config->{'to'},
From => $self->config->{'from'},
Subject => $self->config->{'subject'},
To => $self->config->{ 'to' },
From => $self->config->{ 'from' },
Subject => $self->config->{ 'subject' },
],
body => $mail->{'msg'},
body => $mail->{ 'msg' },
);
# log debug message
$controller->app->log->debug( sprintf "Sending mail:\n%s", $controller->dumper( $email ) );
sendmail($email);
sendmail( $email );
};
if ( $EVAL_ERROR ) {