|
|
|
@ -1,22 +1,27 @@
|
|
|
|
|
class MigrateBankQuotes < ActiveRecord::Migration[5.2]
|
|
|
|
|
def change
|
|
|
|
|
HomeworkBank.all.each do |bank|
|
|
|
|
|
bank.update_column("quotes", bank.homework_commons.count)
|
|
|
|
|
task_count = bank.homework_commons.count
|
|
|
|
|
bank.update_column("quotes", task_count == 0 ? 1 : task_count)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
GtopicBank.all.each do |bank|
|
|
|
|
|
bank.update_column("quotes", bank.graduation_topics.count)
|
|
|
|
|
task_count = bank.graduation_topics.count
|
|
|
|
|
bank.update_column("quotes", task_count == 0 ? 1 : task_count)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
GtaskBank.all.each do |bank|
|
|
|
|
|
bank.update_column("quotes", bank.graduation_tasks.count)
|
|
|
|
|
task_count = bank.graduation_tasks.count
|
|
|
|
|
bank.update_column("quotes", task_count == 0 ? 1 : task_count)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
ExerciseBank.all.each do |bank|
|
|
|
|
|
if bank.container_type == 'Exercise'
|
|
|
|
|
bank.update_column("quotes", bank.exercises.count)
|
|
|
|
|
task_count = bank.exercises.count
|
|
|
|
|
bank.update_column("quotes", task_count == 0 ? 1 : task_count)
|
|
|
|
|
elsif bank.container_type == 'Poll'
|
|
|
|
|
bank.update_column("quotes", bank.polls.count)
|
|
|
|
|
task_count = bank.polls.count
|
|
|
|
|
bank.update_column("quotes", task_count == 0 ? 1 : task_count)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|