From 72d188f228eef2b3a632f3c6824bf034e951f26c Mon Sep 17 00:00:00 2001 From: Kyle Le Date: Mon, 25 Nov 2024 09:35:04 +0700 Subject: [PATCH] Handle nil exception with price override --- .rubocop.yml | 1 + app/controllers/kaui/account_timelines_controller.rb | 8 ++------ app/helpers/kaui/subscription_helper.rb | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2dfa4591..246f8d62 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,6 +8,7 @@ AllCops: - 'app/controllers/kaui/engine_controller.rb' # Too much magic going on NewCops: enable SuggestExtensions: false + TargetRubyVersion: 3.2 Gemspec/RequiredRubyVersion: Enabled: false diff --git a/app/controllers/kaui/account_timelines_controller.rb b/app/controllers/kaui/account_timelines_controller.rb index 5c3d1c40..eaea69b9 100644 --- a/app/controllers/kaui/account_timelines_controller.rb +++ b/app/controllers/kaui/account_timelines_controller.rb @@ -34,20 +34,16 @@ def show def download timeline = Kaui::AccountTimeline.find_by_account_id(params.require(:account_id), 'FULL', options_for_klient) - start_date = params[:startDate] - end_date = params[:endDate] start_date = begin - Date.parse(start_date) + Date.parse(params[:startDate]) rescue StandardError nil end end_date = begin - Date.parse(end_date) + Date.parse(params[:endDate]) rescue StandardError nil end - start_date = params[:startDate].present? ? Date.parse(params[:startDate]) : nil - end_date = params[:endDate].present? ? Date.parse(params[:endDate]) : nil event_type = params[:eventType] @account = timeline.account diff --git a/app/helpers/kaui/subscription_helper.rb b/app/helpers/kaui/subscription_helper.rb index 1b6a1c61..03b34040 100644 --- a/app/helpers/kaui/subscription_helper.rb +++ b/app/helpers/kaui/subscription_helper.rb @@ -98,7 +98,7 @@ def humanized_price_override(sub, separation = ', ', open_bracket = '', close_br '' else current_plan = sub.prices.select { |price| price['phaseType'] == sub.phase_type && price['planName'] == sub.plan_name } - price_override = current_plan.last['fixedPrice'] || current_plan.last['recurringPrice'] + price_override = current_plan.last ? (current_plan.last['fixedPrice'] || current_plan.last['recurringPrice']) : nil if price_override.blank? ''