Fix empty parameter causing db exception

This commit is contained in:
Maximilian Grundke
2018-04-25 13:18:34 +02:00
parent dd55b1faee
commit 9da3d98654

View File

@ -37,7 +37,7 @@ class StatisticsController < ApplicationController
respond_to do |format|
format.html { render 'rfc_activity_history' }
format.json do
interval = params[:interval].to_s.nil? ? 'year' : params[:interval]
interval = params[:interval].to_s.empty? ? '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))