FIX: topic and category exporters were only exporting users who created the first post

This commit is contained in:
Neil Lalonde
2018-01-16 12:51:37 -05:00
parent d7657d8e47
commit f274a5234f
3 changed files with 16 additions and 9 deletions

View File

@@ -75,10 +75,10 @@ module ImportExport
end
user_ids.uniq!
return [] if user_ids.empty?
return User.none if user_ids.empty?
users = User.where(id: user_ids)
export_users(users.to_a)
export_users(users)
end
def export_group_users!
@@ -118,10 +118,9 @@ module ImportExport
return if @export_data[:topics].blank?
topic_ids = @export_data[:topics].pluck(:id)
users = User.joins(:topics).where('topics.id IN (?)', topic_ids).to_a
users.uniq!
users = User.joins(:posts).where('posts.topic_id IN (?)', topic_ids).distinct
export_users(users.to_a)
export_users(users)
end
def export_topic_users!
@@ -132,9 +131,9 @@ module ImportExport
def export_users(users)
data = []
users.reject! { |u| u.id == Discourse::SYSTEM_USER_ID }
users.each do |u|
users.find_each do |u|
next if u.id == Discourse::SYSTEM_USER_ID
x = USER_ATTRS.inject({}) { |h, a| h[a] = u.send(a); h; }
x.merge(bio_raw: u.user_profile.bio_raw,
website: u.user_profile.website,