1. 29 Oct, 2020 1 commit
    • rpereira2's avatar
      Create new column in historical_data called recorded_at · 7f5c758c
      rpereira2 authored
      - Populate recorded_at from created_at or date because created_at
      should accurately tell us when the row was recorded. But created_at
      is not `null: false` so we need to fallback to date.
      - Set a not null constraint on recorded_at.
      - Remove the not null constraint on date since we won't be populating
      this column anymore. The column will be kept for now in case we need to
      go back and check old values. The column can be removed after a
      sufficient amount of time has passed with no issues.
      - Change the HistoricalData model to use recorded_at instead of date.
      7f5c758c
  2. 27 Oct, 2020 3 commits
    • rpereira2's avatar
      Use concurrent helpers in migration to change type · c45879bb
      rpereira2 authored
      Use the concurrent helpers recommended by our migration guide to change
      type of historical_data.date to timestamptz.
      c45879bb
    • rpereira2's avatar
      Update callers of HistoricalData to pass in Time as parameters · 62895180
      rpereira2 authored
      Previously, `HistoricalData.date` was a `date`. When doing date range
      calculations such as `HistoricalData.where(
      Date.parse('2020-10-20')..Date.parse('2020-10-23'))`, any records
      containing 20th or 23rd are included in the result.
      
      However, with `HistoricalData.date` as a timestamp with time zone,
      20th would be included (since the time component is assumed to be 00:00)
      but 23rd would be excluded.
      
      In order to include both days, we need to use
      `.beginning_of_day` and `.end_of_day`. Both methods are time zone aware
      and will use the `Time.zone` if available.
      62895180
    • rpereira2's avatar
  3. 23 Oct, 2020 36 commits