From 553d4ebaa082560cc1de736552de5632a7f388e3 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sun, 10 Nov 2019 19:27:41 +0000 Subject: [PATCH] Fix a few rubocop issues in reports code --- .rubocop_manual_todo.yml | 1 - .../spree/admin/reports_controller_decorator.rb | 4 ++-- .../users_and_enterprises_report.rb | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index c050bda9de..11f3be06ea 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -124,7 +124,6 @@ Metrics/LineLength: - lib/open_food_network/reports/bulk_coop_allocation_report.rb - lib/open_food_network/reports/line_items.rb - lib/open_food_network/sales_tax_report.rb - - lib/open_food_network/users_and_enterprises_report.rb - lib/open_food_network/variant_and_line_item_naming.rb - lib/open_food_network/xero_invoices_report.rb - lib/spree/core/controller_helpers/respond_with_decorator.rb diff --git a/app/controllers/spree/admin/reports_controller_decorator.rb b/app/controllers/spree/admin/reports_controller_decorator.rb index ddafac2733..3a7f5217fc 100644 --- a/app/controllers/spree/admin/reports_controller_decorator.rb +++ b/app/controllers/spree/admin/reports_controller_decorator.rb @@ -258,14 +258,14 @@ Spree::Admin::ReportsController.class_eval do def describe_report(report) name = I18n.t(:name, scope: [:admin, :reports, report]) description = begin - I18n.t!(:description, scope: [:admin, :reports, report]) + I18n.t!(:description, scope: [:admin, :reports, report]) rescue I18n::MissingTranslationData render_to_string( partial: "#{report}_description", layout: false, locals: { report_types: report_types[report] } ).html_safe - end + end { name: name, url: url_for_report(report), description: description } end diff --git a/lib/open_food_network/users_and_enterprises_report.rb b/lib/open_food_network/users_and_enterprises_report.rb index 15de41a883..74e328ee20 100644 --- a/lib/open_food_network/users_and_enterprises_report.rb +++ b/lib/open_food_network/users_and_enterprises_report.rb @@ -6,7 +6,9 @@ module OpenFoodNetwork @compile_table = compile_table # Convert arrays of ids to comma delimited strings - @params[:enterprise_id_in] = @params[:enterprise_id_in].join(',') if @params[:enterprise_id_in].is_a? Array + if @params[:enterprise_id_in].is_a? Array + @params[:enterprise_id_in] = @params[:enterprise_id_in].join(',') + end @params[:user_id_in] = @params[:user_id_in].join(',') if @params[:user_id_in].is_a? Array end @@ -104,8 +106,17 @@ module OpenFoodNetwork [(a["created_at"].nil? ? 0 : 1), a["name"], b["relationship_type"], a["user_email"]] <=> [(b["created_at"].nil? ? 0 : 1), b["name"], a["relationship_type"], b["user_email"]] else - [DateTime.parse(b["created_at"]).in_time_zone, a["name"], b["relationship_type"], a["user_email"]] <=> - [DateTime.parse(a["created_at"]).in_time_zone, b["name"], a["relationship_type"], b["user_email"]] + [ + DateTime.parse(b["created_at"]).in_time_zone, + a["name"], + b["relationship_type"], + a["user_email"] + ] <=> [ + DateTime.parse(a["created_at"]).in_time_zone, + b["name"], + a["relationship_type"], + b["user_email"] + ] end end end