Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportService::OnSheet::StarとImportService::OnSheet::Titleの実行を追加する #59

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions lib/tasks/db/reconstruction.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ namespace :db do
Rake::Task['db:migrate:reset'].invoke

ActiveRecord::Base.transaction do
puts "[#{Time.zone.now}] ImportService::OnSheet::Star の実行を開始します。"
ImportService::OnSheet::Star.new(
csv_filepath: Rails.root.join('db/csv_on_sheet/basic_attributes/stars.csv')
).execute
puts "[#{Time.zone.now}] ImportService::OnSheet::Star の実行が終了しました。"

puts "[#{Time.zone.now}] ImportService::OnSheet::Title の実行を開始します。"
ImportService::OnSheet::Title.new(
csv_filepath: Rails.root.join('db/csv_on_sheet/products/titles.csv')
).execute
puts "[#{Time.zone.now}] ImportService::OnSheet::Title の実行が終了しました。"
show_message_and_execute(
'ImportService::OnSheet::Star',
Rails.root.join(
Rails.root.join('db/csv_on_sheet/basic_attributes/stars.csv')
)
)

show_message_and_execute(
'ImportService::OnSheet::Title',
Rails.root.join(
Rails.root.join('db/csv_on_sheet/products/titles.csv')
)
)
end

# ERD を出力する
Expand All @@ -34,3 +36,14 @@ namespace :db do
end
end
end

def show_message_and_execute(class_name_string, csv_filepath)
puts "[#{Time.zone.now}] #{class_name_string} の実行を開始します。"

klass = class_name_string.constantize
klass.new(
csv_filepath:
).execute

puts "[#{Time.zone.now}] #{class_name_string} の実行が終了しました。"
end
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions scripts/reconstruction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euxo pipefail

bundle exec rails db:reconstruction:execute

exit 0