Skip to content

Commit

Permalink
Merge pull request #148 from seapy/master
Browse files Browse the repository at this point in the history
happyrails 마이그레이션 task 추가
  • Loading branch information
seapy committed Jan 17, 2015
2 parents eb286d5 + b1094cd commit d00bf50
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/tasks/oldrorla.rake
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,35 @@ namespace :oldrorla do

Rails.logger.info "END oldrorla:rblog"
end

desc "happyrails(to rblogs) 마이그레이션"
task :happyrails => [:setup_logger, :user] do
items = Oj.load(File.read('tmp/json/happyrails.json'))
items.each do |item|
rblog = Rblog.create(
title: item[:title],
content: item[:content],
shared: true,
writer: @user,
created_at: item[:created_at],
updated_at: item[:updated_at],
tag_list: item[:tags]
)

item[:hit].times.each do
Impression.create(
impressionable_type: "Rblog",
impressionable_id: rblog.id,
user_id: @user.id,
controller_name: "rblogs",
action_name: "show",
request_hash: SecureRandom.hex(64),
session_hash: SecureRandom.hex(32),
ip_address: "127.0.0.1"
)
end
end

Rails.logger.info "END oldrorla:happyrails"
end
end

0 comments on commit d00bf50

Please sign in to comment.