Skip to content

Commit

Permalink
improve awon download filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbradford committed Jul 27, 2023
1 parent 8c625dc commit 88d52eb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/controllers/awon_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ def download_data
render plain: text
end
format.csv do
filename = begin
"#{stn.name} #{@db_class.description} - #{start_date} to #{end_date}.csv"
rescue
"awon data.csv"
end
text = @db_class.csv_header(use_abbrevs, @ahrs)
text += @results.collect { |rec| rec.to_csv(@ahrs) }.join("")
# render plain: text
send_data text, filename: "awon_data.csv"
send_data(text, filename:)
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/t401.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class T401 < ApplicationRecord

belongs_to :awon_station

def self.description
"Five-Minute Precip and Wind"
end

def self.attr_human_readables
[
["date", "Date"],
Expand Down
4 changes: 4 additions & 0 deletions app/models/t403.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class T403 < ApplicationRecord

belongs_to :awon_station

def self.description
"Pre-2000 Half-Hourly Weather and Soil"
end

def self.attr_human_readables
[
["date", "Date"],
Expand Down
4 changes: 4 additions & 0 deletions app/models/t406.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class T406 < ApplicationRecord

belongs_to :awon_station

def self.description
"Hourly Weather and Soil"
end

def self.attr_human_readables
[
["date", "Date"],
Expand Down
4 changes: 4 additions & 0 deletions app/models/t411.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class T411 < ApplicationRecord

belongs_to :awon_station

def self.description
"Daily Weather"
end

def self.attr_human_readables
[
["date", "Date"],
Expand Down
4 changes: 4 additions & 0 deletions app/models/t412.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class T412 < ApplicationRecord

belongs_to :awon_station

def self.description
"Daily Soil"
end

def self.attr_human_readables
[
["date", "Date"],
Expand Down

0 comments on commit 88d52eb

Please sign in to comment.