Skip to content

Commit

Permalink
Handle nil exception with price override
Browse files Browse the repository at this point in the history
  • Loading branch information
tungleduyxyz committed Nov 28, 2024
1 parent 53acbc1 commit 72d188f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/kaui/account_timelines_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/kaui/subscription_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
''
Expand Down

0 comments on commit 72d188f

Please sign in to comment.