fix errors if no csv data or incorrect last group call specified
This commit is contained in:
parent
fa333400c8
commit
3f19baae37
@ -104,8 +104,11 @@ class FeedController < ApplicationController
|
|||||||
# put feeds in correct order (oldest to most recent)
|
# put feeds in correct order (oldest to most recent)
|
||||||
last_feeds.reverse!
|
last_feeds.reverse!
|
||||||
|
|
||||||
|
# check if the correct param is present by getting the param name from arg, e.g.: 'median' from 'medians'
|
||||||
|
correct_params_present = params[arg.chop.to_sym].present?
|
||||||
|
|
||||||
feeds_into = self.method("feeds_into_#{arg}")
|
feeds_into = self.method("feeds_into_#{arg}")
|
||||||
feed = feeds_into.call(last_feeds, params).last if last_feeds.length > 0
|
feed = feeds_into.call(last_feeds, params).last if last_feeds.length > 0 && correct_params_present
|
||||||
create_group_result(feed)
|
create_group_result(feed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -272,6 +272,7 @@ module FeedHelper
|
|||||||
|
|
||||||
# slice feed into medians
|
# slice feed into medians
|
||||||
def feeds_into_medians(feeds, params)
|
def feeds_into_medians(feeds, params)
|
||||||
|
|
||||||
# convert timescale (minutes) into seconds
|
# convert timescale (minutes) into seconds
|
||||||
seconds = params[:median].to_i * 60
|
seconds = params[:median].to_i * 60
|
||||||
# get floored time ranges
|
# get floored time ranges
|
||||||
@ -355,7 +356,7 @@ module FeedHelper
|
|||||||
# checks for valid timescale
|
# checks for valid timescale
|
||||||
def timeparam_valid?(timeparam)
|
def timeparam_valid?(timeparam)
|
||||||
valid_minutes = [10, 15, 20, 30, 60, 240, 720, 1440]
|
valid_minutes = [10, 15, 20, 30, 60, 240, 720, 1440]
|
||||||
if timeparam and valid_minutes.include?(timeparam.to_i)
|
if timeparam.present? && valid_minutes.include?(timeparam.to_i)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
<% if @success %><%= CSV.generate_line @csv_headers %><% row = [] %><% @csv_headers.each do |attr| %><% row.push(@feed.send(attr)) %><% end %><%= CSV.generate_line row %><% else %>-1<% end %>
|
<% if @success && @csv_headers.present? %><%= CSV.generate_line @csv_headers %><% row = [] %><% @csv_headers.each do |attr| %><% row.push(@feed.send(attr)) %><% end %><%= CSV.generate_line row %><% else %>-1<% end %>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user