Guest User

Untitled

a guest
Feb 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. # File lib/active_warehouse/builder/date_dimension_builder.rb, line 31
  2. 31: def build(options={})
  3. 32: records = []
  4. 33: date = start_date.to_time
  5. 34: while date <= end_date.to_time
  6. 35: record = {}
  7. 36: record[:date] = date.strftime("%m/%d/%Y")
  8. 37: record[:full_date_description] = date.strftime("%B %d,%Y")
  9. 38: record[:day_of_week] = date.strftime("%A")
  10. 39: #record[:day_number_in_epoch] = date.to_i / 24
  11. 40: #record[:week_number_in_epoch] = date.to_i / (24 * 7)
  12. 41: #record[:month_number_in_epoch] = date.to_i / (24 * 7 * 30)
  13. 42: record[:day_number_in_calendar_month] = date.day
  14. 43: record[:day_number_in_calendar_year] = date.yday
  15. 44: record[:day_number_in_fiscal_month] = date.day # should this be different from CY?
  16. 45: record[:day_number_in_fiscal_year] = date.fiscal_year_yday
  17. 46: #record[:last_day_in_week_indicator] =
  18. 47: #record[:last_day_in_month_indicator] =
  19. 48: #record[:calendar_week_ending_date] =
  20. 49: record[:calendar_week] = "Week #{date.week}"
  21. 50: record[:calendar_week_number_in_year] = date.week
  22. 51: record[:calendar_month_name] = date.strftime("%B")
  23. 52: record[:calendar_month_number_in_year] = date.month
  24. 53: record[:calendar_year_month] = date.strftime("%Y-%m")
  25. 54: record[:calendar_quarter] = "Q#{date.quarter}"
  26. 55: record[:calendar_quarter_number_in_year] = date.quarter
  27. 56: record[:calendar_year_quarter] = "#{date.strftime('%Y')}-#{record[:calendar_quarter]}"
  28. 57: #record[:calendar_half_year] =
  29. 58: record[:calendar_year] = "#{date.year}"
  30. 59: record[:fiscal_week] = "FY Week #{date.fiscal_year_week}"
  31. 60: record[:fiscal_week_number_in_year] = date.fiscal_year_week
  32. 61: record[:fiscal_month] = date.fiscal_year_month
  33. 62: record[:fiscal_month_number_in_year] = date.fiscal_year_month
  34. 63: record[:fiscal_year_month] = "FY#{date.fiscal_year}-" + date.fiscal_year_month.to_s.rjust(2, '0')
  35. 64: record[:fiscal_quarter] = "FY Q#{date.fiscal_year_quarter}"
  36. 65: record[:fiscal_year_quarter] = "FY#{date.fiscal_year}-Q#{date.fiscal_year_quarter}"
  37. 66: record[:fiscal_year_quarter_number] = date.fiscal_year_quarter
  38. 67: #record[:fiscal_half_year] =
  39. 68: record[:fiscal_year] = "FY#{date.fiscal_year}"
  40. 69: record[:fiscal_year_number] = date.fiscal_year
  41. 70: record[:holiday_indicator] = holiday_indicators.include?(date) ? 'Holiday' : 'Nonholiday'
  42. 71: record[:weekday_indicator] = weekday_indicators[date.wday]
  43. 72: record[:selling_season] = 'None'
  44. 73: record[:major_event] = 'None'
  45. 74: record[:sql_date_stamp] = date
  46. 75:
  47. 76: records << record
  48. 77: date = date.tomorrow
  49. 78: end
  50. 79: records
  51. 80: end
Add Comment
Please, Sign In to add comment