From 392d7f3a7ad80e5e7c02ba01970bdddf4288f5b1 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Mon, 12 Jun 2017 23:30:40 +0100 Subject: [PATCH] Fixed issue with undefined env var, and bad reverse counting of days --- lib/Pear/LocalLoop/Command/dev_data.pm | 2 +- lib/Pear/LocalLoop/Command/dev_transactions.pm | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Pear/LocalLoop/Command/dev_data.pm b/lib/Pear/LocalLoop/Command/dev_data.pm index 1b5053d..7c6b04e 100644 --- a/lib/Pear/LocalLoop/Command/dev_data.pm +++ b/lib/Pear/LocalLoop/Command/dev_data.pm @@ -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; } diff --git a/lib/Pear/LocalLoop/Command/dev_transactions.pm b/lib/Pear/LocalLoop/Command/dev_transactions.pm index 17a31c8..2f4fe92 100644 --- a/lib/Pear/LocalLoop/Command/dev_transactions.pm +++ b/lib/Pear/LocalLoop/Command/dev_transactions.pm @@ -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', {