Review queue filled with "pending" users not clearing after disabling "must approve users" site setting

AI-generated summary

In a Discourse support thread, andy reports that after disabling the “must approve users” setting, 12,000 imported users remain stuck in the review queue. These users were imported from vBulletin before the review queue existed, and the setting was later enabled and disabled during internal testing. codinghorror directs the inquiry to eviltrout, who offers two solutions via Rails console: to delete all pending reviewable users without preserving history, run ReviewableUser.pending.delete_all; to approve them all programmatically while preserving history, run ReviewableUser.pending.each { |r| r.perform(Discourse.system_user, :approve_user) }. The issue stems from the setting change not automatically clearing the queue for previously imported users.

On v2.3.0.beta9 +10

I have about 12,000 items waiting in the review queue, all of which are users from a vbulletin import. When the data was imported about a month ago the review queue didn’t exist as discourse was a few versions behind.

Between importing and upgrading versions, must approve users in the site settings was enabled for testing the platform internally with my team. Eventually we turned this setting off before reopening to the public.

Problem: I have 12,000 imported users who “need review” when disabling the site setting should have dequeued them. Is there any way I can clear the queue en masse without having to redundantly approve them by hand?

I believe @eviltrout can advise you on this.

It depends if you want to keep the history around of the reviewable or not.

The nuclear option if you don’t care about history is to open a rails console and do this:

ReviewableUser.pending.delete_all

If you want to approve them you can do this:

ReviewableUser.pending.each { |r| r.perform(Discourse.system_user, :approve_user) }