dev_hss
cxt 5 years ago
parent 67395e72a7
commit a7cfb3b078

@ -30,7 +30,7 @@ class Users::QuestionBanksController < Users::BaseController
.where(commit_status: 1, exercises: { exercise_bank_id: question_bank_ids })
.group('exercises.exercise_bank_id').count
when 'poll' then
PollUser.joins(:poll).where(polls: { exercise_bank_id: question_bank_ids })
PollUser.joins(:poll).where(commit_status: 1, polls: { exercise_bank_id: question_bank_ids })
.group('polls.exercise_bank_id').count
when 'gtask' then
GraduationWork.has_committed.joins(:graduation_task)

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