Migrate marks to ratings on feedbacks
This commit is contained in:
parent
4103861f90
commit
e9a262947f
1 changed files with 19 additions and 0 deletions
19
lib/tasks/2018_08_27_migrate_feedbacks.rake
Normal file
19
lib/tasks/2018_08_27_migrate_feedbacks.rake
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
require Rails.root.join("lib", "tasks", "task_helper")
|
||||||
|
|
||||||
|
namespace :'2018_08_27_migrate_feedbacks' do
|
||||||
|
task run: :environment do
|
||||||
|
MAPPING = {
|
||||||
|
0 => Feedback.ratings.fetch(:unhappy),
|
||||||
|
1 => Feedback.ratings.fetch(:neutral),
|
||||||
|
2 => Feedback.ratings.fetch(:happy)
|
||||||
|
}
|
||||||
|
|
||||||
|
MAPPING.keys.each do |mark|
|
||||||
|
rating = MAPPING[mark]
|
||||||
|
|
||||||
|
Feedback
|
||||||
|
.where(mark: mark)
|
||||||
|
.update_all(rating: rating)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue