Fixed issue with undefined env var, and bad reverse counting of days

This commit is contained in:
Tom Bloor 2017-06-12 23:30:40 +01:00
parent 606d5bffc2
commit 392d7f3a7a
2 changed files with 7 additions and 3 deletions

View file

@ -18,7 +18,7 @@ sub run {
return;
}
if ( $ENV{MOJO_MODE} eq 'production' || $self->app->mode eq 'production' ) {
if ( ( defined( $ENV{MOJO_MODE} ) && $ENV{MOJO_MODE} eq 'production' ) || $self->app->mode eq 'production' ) {
say "Will not run dev data fixtures in production!";
return;
}

View file

@ -24,7 +24,7 @@ sub run {
return;
}
if ( $ENV{MOJO_MODE} eq 'production' || $self->app->mode eq 'production' ) {
if ( ( defined( $ENV{MOJO_MODE} ) && $ENV{MOJO_MODE} eq 'production' ) || $self->app->mode eq 'production' ) {
say "Will not run dev data fixtures in production!";
return;
}
@ -61,8 +61,12 @@ sub run {
$number = 1;
}
unless ( defined $count ) {
$count = 0;
}
for my $day_sub ( 0 .. $count ) {
$datetime->subtract( days => $day_sub );
$datetime->subtract( days => 1 );
for ( 1 .. $number ) {
for my $user_result ( $user_rs->all ) {
$user_result->create_related( 'transactions', {