mirror of
https://gitlab.com/depesz/explain.depesz.com.git
synced 2024-11-28 08:58:52 +02:00
perltidy code
This commit is contained in:
parent
06503d10d9
commit
f9e0abffe5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
log
|
log
|
||||||
explain.production.json
|
explain.production.json
|
||||||
.vagrant
|
.vagrant
|
||||||
|
*.beforeTidy
|
||||||
|
@ -19,9 +19,11 @@ sub startup {
|
|||||||
# array format
|
# array format
|
||||||
my $use_secret = $config->{ secret } || 'Xwyfe-_d:yGDr+p][Vs7Kk+e3mmP=c_|s7hvExF=b|4r4^gO|';
|
my $use_secret = $config->{ secret } || 'Xwyfe-_d:yGDr+p][Vs7Kk+e3mmP=c_|s7hvExF=b|4r4^gO|';
|
||||||
if ( $self->can( 'secrets' ) ) {
|
if ( $self->can( 'secrets' ) ) {
|
||||||
|
|
||||||
# We're on Mojolicious 4.63 or newer
|
# We're on Mojolicious 4.63 or newer
|
||||||
$self->secrets( [ $use_secret ] );
|
$self->secrets( [ $use_secret ] );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
# We're on old Mojolicious
|
# We're on old Mojolicious
|
||||||
$self->secret( $use_secret );
|
$self->secret( $use_secret );
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ sub login {
|
|||||||
|
|
||||||
if ( my $user = $self->database->user_login( $username, $password ) ) {
|
if ( my $user = $self->database->user_login( $username, $password ) ) {
|
||||||
$self->flash( 'message' => 'User logged in.' );
|
$self->flash( 'message' => 'User logged in.' );
|
||||||
$self->session( 'user' => $username );
|
$self->session( 'user' => $username );
|
||||||
$self->session( 'admin' => $user->{ 'admin' } );
|
$self->session( 'admin' => $user->{ 'admin' } );
|
||||||
$self->redirect_to( 'new-explain' );
|
$self->redirect_to( 'new-explain' );
|
||||||
}
|
}
|
||||||
@ -172,9 +172,9 @@ sub new_optimization {
|
|||||||
|
|
||||||
return $self->redirect_to( 'new-explain', status => 404 ) unless $original_plan;
|
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_plan_id' } = $original_plan_id;
|
||||||
$self->stash->{ 'original_title' } = $original_title;
|
$self->stash->{ 'original_title' } = $original_title;
|
||||||
|
|
||||||
return $self->render( 'controller/index' );
|
return $self->render( 'controller/index' );
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ sub show {
|
|||||||
|
|
||||||
# Fetch path of optimizations
|
# Fetch path of optimizations
|
||||||
$self->stash->{ optimization_path } = $self->database->get_optimization_path( $id );
|
$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
|
# render will be called automatically
|
||||||
return;
|
return;
|
||||||
@ -403,15 +403,17 @@ sub info {
|
|||||||
next if $module =~ m{^\.?/};
|
next if $module =~ m{^\.?/};
|
||||||
$module =~ s/\.pm$//;
|
$module =~ s/\.pm$//;
|
||||||
$module =~ s#/#::#g;
|
$module =~ s#/#::#g;
|
||||||
push @versions, {
|
push @versions,
|
||||||
'module' => $module,
|
{
|
||||||
|
'module' => $module,
|
||||||
'version' => $module->VERSION,
|
'version' => $module->VERSION,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
$self->stash( 'modules' => \@versions );
|
$self->stash( 'modules' => \@versions );
|
||||||
$self->stash( 'perl' => {
|
$self->stash(
|
||||||
|
'perl' => {
|
||||||
'version' => $PERL_VERSION,
|
'version' => $PERL_VERSION,
|
||||||
'binary' => $Config{'perlpath'} . $Config{'_exe'},
|
'binary' => $Config{ 'perlpath' } . $Config{ '_exe' },
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -419,10 +421,11 @@ sub info {
|
|||||||
|
|
||||||
sub status {
|
sub status {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
if ($self->database->ping()) {
|
if ( $self->database->ping() ) {
|
||||||
$self->render('text' => 'OK', status => 200);
|
$self->render( 'text' => 'OK', status => 200 );
|
||||||
} else {
|
}
|
||||||
$self->render('text' => 'DB FAILED', status => 500);
|
else {
|
||||||
|
$self->render( 'text' => 'DB FAILED', status => 500 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ sub user_login {
|
|||||||
my $crypted = crypt( $password, $row[ 0 ] );
|
my $crypted = crypt( $password, $row[ 0 ] );
|
||||||
|
|
||||||
return if $crypted ne $row[ 0 ];
|
return if $crypted ne $row[ 0 ];
|
||||||
return { 'admin' => $row[1] };
|
return { 'admin' => $row[ 1 ] };
|
||||||
}
|
}
|
||||||
|
|
||||||
sub user_change_password {
|
sub user_change_password {
|
||||||
@ -262,10 +262,9 @@ sub get_plan {
|
|||||||
|
|
||||||
sub get_optimization_path {
|
sub get_optimization_path {
|
||||||
my $self = shift;
|
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 (
|
WITH RECURSIVE path AS (
|
||||||
SELECT id, title, optimization_for, 0 as level FROM plans WHERE id = ? and not is_deleted
|
SELECT id, title, optimization_for, 0 as level FROM plans WHERE id = ? and not is_deleted
|
||||||
union all
|
union all
|
||||||
@ -290,9 +289,9 @@ sub get_optimization_path {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub get_optimizations_for {
|
sub get_optimizations_for {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($plan_id) = @_;
|
my ( $plan_id ) = @_;
|
||||||
my $rows = $self->dbh->selectall_arrayref(
|
my $rows = $self->dbh->selectall_arrayref(
|
||||||
'select id, title from plans where optimization_for = ? and not is_deleted',
|
'select id, title from plans where optimization_for = ? and not is_deleted',
|
||||||
{ Slice => {} },
|
{ Slice => {} },
|
||||||
$plan_id
|
$plan_id
|
||||||
|
@ -21,17 +21,17 @@ sub register {
|
|||||||
eval {
|
eval {
|
||||||
my $email = Email::Simple->create(
|
my $email = Email::Simple->create(
|
||||||
header => [
|
header => [
|
||||||
To => $self->config->{'to'},
|
To => $self->config->{ 'to' },
|
||||||
From => $self->config->{'from'},
|
From => $self->config->{ 'from' },
|
||||||
Subject => $self->config->{'subject'},
|
Subject => $self->config->{ 'subject' },
|
||||||
],
|
],
|
||||||
body => $mail->{'msg'},
|
body => $mail->{ 'msg' },
|
||||||
);
|
);
|
||||||
|
|
||||||
# log debug message
|
# log debug message
|
||||||
$controller->app->log->debug( sprintf "Sending mail:\n%s", $controller->dumper( $email ) );
|
$controller->app->log->debug( sprintf "Sending mail:\n%s", $controller->dumper( $email ) );
|
||||||
|
|
||||||
sendmail($email);
|
sendmail( $email );
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user