diff --git a/lib/Pear/LocalLoop/Controller/Api/Upload.pm b/lib/Pear/LocalLoop/Controller/Api/Upload.pm index 61f1d2b..dea1f10 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Upload.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Upload.pm @@ -198,7 +198,7 @@ sub post_upload { ( defined $file ? ( proof_image => $file ) : () ), purchase_time => $c->format_db_datetime($purchase_time), essential => ( defined $essential ? $essential : 0 ), - distance => ( defined $category ? $category : undef ), + distance => $distance, } ); @@ -227,7 +227,7 @@ sub post_upload { value => $transaction_value * 100000, start_time => $c->format_db_datetime($purchase_time), essential => ( defined $essential ? $essential : 0 ), - distance => ( defined $category ? $category : undef ), + distance => $distance, category_id => ( defined $category ? $category : undef ), recurring_period => $recurring_period, }); @@ -243,18 +243,22 @@ sub post_category { my $c = shift; my $self = $c; - my $categories = { ids => [], names => [] }; - my $category_rs = $c->schema->resultset('Category'); - for ( $category_rs->all ) { - push @{ $categories->{ ids } }, $_->get_column('id'); - push @{ $categories->{ names } }, $_->get_column('name'); - } + # for ( $category_rs->all ) { + # push @{ $categories->{ ids } }, $_->get_column('id'); + # push @{ $categories->{ names } }, $_->get_column('name'); + # } + my @category_list = ( + map {{ + id => $_->id, + name => $_->name, + }} $category_rs->all + ); return $self->render( json => { success => Mojo::JSON->true, - categories => $categories, + categories => \@category_list, }); } diff --git a/lib/Pear/LocalLoop/Plugin/Datetime.pm b/lib/Pear/LocalLoop/Plugin/Datetime.pm index 1f79e45..c6f2e55 100644 --- a/lib/Pear/LocalLoop/Plugin/Datetime.pm +++ b/lib/Pear/LocalLoop/Plugin/Datetime.pm @@ -66,6 +66,7 @@ sub register { $app->helper( format_iso_datetime => sub { my ( $c, $datetime_obj ) = @_; + return unless defined $datetime_obj; return $c->iso_datetime_parser->format_datetime( $datetime_obj, );