mirror of
https://github.com/elisspace/FxLifeSheet.git
synced 2026-08-29 15:44:00 +00:00
Tag day of the week & month of the year while tagging days
This commit is contained in:
@@ -18,6 +18,8 @@ ruby ../clone_heroku_db.rb
|
||||
be ruby importers/tag_days/tag_days.rb
|
||||
```
|
||||
|
||||
This will also backfill the day of the week and the month of the year
|
||||
|
||||
### Step 2: Import historic location based on Swarm & Telegram
|
||||
|
||||
```
|
||||
|
||||
@@ -100,6 +100,7 @@ module Importers
|
||||
end
|
||||
|
||||
# e.g. precise Swarm check-in time
|
||||
# or for backfilling the day of the week or month of the year
|
||||
def insert_row_for_timestamp(timestamp:, key:, type:, value:, question: nil, source:, import_id:, matched_date:)
|
||||
raise "invalid type #{type}" unless ["boolean", "range", "number", "text"].include?(type)
|
||||
|
||||
|
||||
@@ -84,6 +84,30 @@ module Importers
|
||||
elsif row[:matcheddate] != date
|
||||
raise "Something seems off here: #{row[:matcheddate]} != #{date}"
|
||||
end
|
||||
|
||||
# Insert the day of the week for this specific entry
|
||||
insert_row_for_timestamp(
|
||||
timestamp: Time.at(row[:timestamp] / 1000),
|
||||
key: "dateDayOfTheWeek",
|
||||
value: Date::DAYNAMES[date.wday],
|
||||
question: "Day of the week",
|
||||
type: "text",
|
||||
import_id: import_id,
|
||||
matched_date: date,
|
||||
source: "tag_days"
|
||||
)
|
||||
|
||||
# Insert the month of the year for this specific entry
|
||||
insert_row_for_timestamp(
|
||||
timestamp: Time.at(row[:timestamp] / 1000),
|
||||
key: "dateMonthOfTheYear",
|
||||
value: date.strftime("%B"),
|
||||
question: "Month of the year",
|
||||
type: "text",
|
||||
import_id: import_id,
|
||||
matched_date: date,
|
||||
source: "tag_days"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -92,6 +116,10 @@ module Importers
|
||||
def all_dates
|
||||
@_all_dates ||= {}
|
||||
end
|
||||
|
||||
def import_id
|
||||
@_import_id ||= SecureRandom.hex
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user