FIX: Vanilla importer fixes (PR #14699)

Small fixes to the regular Vanilla importer.

GitHub

@ldmosquera It would be nice to read in your commit message why you did these changes to the query

@ldmosquera It would be nice to read in your commit message why you did these changes to the query

sorry, I just saw this.

pry(main)> user_emails_in_conversation = [ 'yaddity@yadda.com' ]
=> ["yaddity@yadda.com"]
pry(main)> User.where("email IN (?)", user_emails_in_conversation).pluck(:username).to_a
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column "email" does not exist
LINE 1: SELECT "users"."username" FROM "users" WHERE (email IN ('yad...
                                                      ^

from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.3.3/lib/patches/db/pg.rb:69:in `exec_params'
Caused by PG::UndefinedColumn: ERROR:  column "email" does not exist
LINE 1: SELECT "users"."username" FROM "users" WHERE (email IN ('yad...
                                                      ^

from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-mini-profiler-2.3.3/lib/patches/db/pg.rb:69:in `exec_params'

ie. email no longer lives in the User table; there’s a separate UserEmail record and a User can have many.

I’ll be more verbose in PRs in the future.