1
0
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:
Felix Krause
2022-01-29 15:48:04 +01:00
parent e32b5db232
commit 5188dd6816
3 changed files with 31 additions and 0 deletions

View File

@@ -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
```

View File

@@ -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)

View File

@@ -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