diff --git a/app/controllers/awon_controller.rb b/app/controllers/awon_controller.rb index 7ca6630..0df00e1 100644 --- a/app/controllers/awon_controller.rb +++ b/app/controllers/awon_controller.rb @@ -80,7 +80,13 @@ def download_data end format.csv do filename = begin - "#{stn.name} #{@db_class.description} - #{start_date} to #{end_date}.csv" + str = "#{stn.name} #{@db_class.description}" + if @results.exists? + earliest = @results.minimum(:date) + latest = @results.maximum(:date) + str += " #{earliest} to #{latest}" + end + str + ".csv" rescue "awon data.csv" end