Permalink
Browse files

fixed daily weekly tsd series exports

  • Loading branch information...
1 parent 01d313f commit 9ac1be3c64ab62dc1ca0078bbe09bada765a08f5 @bentut committed Dec 8, 2012
Showing with 20 additions and 13 deletions.
  1. +7 −2 app/models/series.rb
  2. +7 −6 config/initializers/date_extension.rb
  3. +5 −5 lib/tasks/exports.rake
  4. +1 −0 public/rake_time.csv
View
@@ -710,9 +710,14 @@ def tsd_string
dps = data
dates = dps.keys.sort
- data_string+= "#{name.split(".")[0].to_s.ljust(16," ")}#{as.description.ljust(64, " ")}\r\n"
- data_string+= "#{lm.month.to_s.rjust(34," ")}/#{lm.day.to_s.rjust(2," ")}/#{lm.year.to_s[2..4]}0800#{dates[0].to_date.tsd_start(frequency)}#{dates[-1].to_date.tsd_end(frequency)}#{Series.code_from_frequency frequency} 0 \r\n"
+ #this could stand to be much more sophisticated and actually look at the dates. I think this will suffice, though - BT
+ day_switches = "0 "
+ day_switches = "0 0000000" if frequency == "week"
+ day_switches[10 + dates[0].to_date.wday] = '1' if frequency == "week"
+ day_switches = "0 1111111" if frequency == "day"
+ data_string+= "#{name.split(".")[0].to_s.ljust(16," ")}#{as.description.ljust(64, " ")}\r\n"
+ data_string+= "#{lm.month.to_s.rjust(34," ")}/#{lm.day.to_s.rjust(2," ")}/#{lm.year.to_s[2..4]}0800#{dates[0].to_date.tsd_start(frequency)}#{dates[-1].to_date.tsd_end(frequency)}#{Series.code_from_frequency frequency} #{day_switches}\r\n"
sci_data = {}
dps.each do |date_string, val|
@@ -26,15 +26,16 @@ def semi_i
end
def tsd_start(f)
- return "#{self.year}0100" if f == "year"
- return semi_i.to_s+"00" if f == "semi"
- return quarter_i.to_s+"00" if f == "quarter"
- return month_i.to_s+"00" if f == "month"
- return Date.parse(self).gsub("-","") if f == "week"
- return Date.parse(self).gsub("-","") if f == "day"
+ return "#{self.year}0100" if f == "year"
+ return semi_i.to_s+"00" if f == "semi"
+ return quarter_i.to_s+"00" if f == "quarter"
+ return month_i.to_s+"00" if f == "month"
+ return (self - self.wday).to_s.gsub("-","") if f == "week"
+ return self.to_s.gsub("-","") if f == "day"
end
def tsd_end(f)
+ return (self - self.wday + 6).to_s.gsub("-","") if f == "week"
tsd_start(f)
end
View
@@ -22,11 +22,11 @@ end
task :tsd_exports => :environment do
t = Time.now
path = "/Volumes/UHEROwork/data/BnkLists/"
- [ "bea_a", "bls_a", "census_a", "jp_a", "misc_a", "tax_a", "tour_a", "us_a",
- "bea_s", "bls_s",
- "bea_q", "bls_q", "census_q", "jp_q", "misc_q", "tax_q", "tour_q", "us_q",
- "bls_m", "jp_m", "misc_m", "tax_m", "tour_m", "us_m",
- "tour_w", "tour_d" ].each do |bank|
+ # [ "bea_a", "bls_a", "census_a", "jp_a", "misc_a", "tax_a", "tour_a", "us_a",
+ # "bea_s", "bls_s",
+ # "bea_q", "bls_q", "census_q", "jp_q", "misc_q", "tax_q", "tour_q", "us_q",
+ # "bls_m", "jp_m", "misc_m", "tax_m", "tour_m", "us_m",
+[ "tour_w", "tour_d" ].each do |bank|
# ["bls_m"].each do |bank|
t = Time.now
frequency_code = bank.split("_")[1].upcase
View
@@ -41,3 +41,4 @@ aremos_exports,66.25,2012-12-07 06:50:06 -1000,2012-12-07 06:51:13 -1000
tsd_exports,1.35,2012-12-07 06:58:10 -1000,2012-12-07 06:58:11 -1000
gen_prognoz_diffs,0.33,2012-12-07 07:41:53 -1000,2012-12-07 07:41:53 -1000
gen_prognoz_diffs,250.67,2012-12-07 08:07:50 -1000,2012-12-07 08:12:01 -1000
+tsd_exports,8.95,2012-12-07 17:38:43 -1000,2012-12-07 17:38:51 -1000

0 comments on commit 9ac1be3

Please sign in to comment.