Use sane default values

This commit is contained in:
Maximilian Grundke
2018-04-24 16:58:31 +02:00
parent 15519ae599
commit dd55b1faee
2 changed files with 6 additions and 7 deletions

View File

@ -37,9 +37,9 @@ class StatisticsController < ApplicationController
respond_to do |format|
format.html { render 'rfc_activity_history' }
format.json do
interval = params[:interval] || 'year'
from = DateTime.strptime(params[:from], '%Y-%M-%D') rescue DateTime.new(0)
to = DateTime.strptime(params[:to], '%Y-%M-%D') rescue DateTime.now
interval = params[:interval].to_s.nil? ? 'year' : params[:interval]
from = DateTime.strptime(params[:from], '%Y-%m-%d') rescue DateTime.new(0)
to = DateTime.strptime(params[:to], '%Y-%m-%d') rescue DateTime.now
render(json: ranged_rfc_data(interval, from, to))
end
end