Skip to content

A platform for community discussion. Free, open, simple.

UX: include post ID in user data export (#38129)

Krisc3b99649b705
diff --git a/app/jobs/regular/export_user_archive.rb b/app/jobs/regular/export_user_archive.rb
index 5508c2a10f8..a5035f0e4b7 100644
--- a/app/jobs/regular/export_user_archive.rb
+++ b/app/jobs/regular/export_user_archive.rb
@@ -36,6 +36,7 @@ module Jobs
like_count
reply_count
url
+ post_id
created_at
],
user_archive_profile: %w[location website bio views],
@@ -205,7 +206,7 @@ module Jobs
Post
.includes(topic: :category)
.where(user_id: @archive_for_user.id)
- .select(:topic_id, :post_number, :raw, :cooked, :like_count, :reply_count, :created_at)
+ .select(:id, :topic_id, :post_number, :raw, :cooked, :like_count, :reply_count, :created_at)
.order(:created_at)
.with_deleted
.each { |user_archive| yield get_user_archive_fields(user_archive) }
@@ -599,6 +600,7 @@ module Jobs
"categories" => categories,
"is_pm" => is_pm,
"url" => url,
+ "post_id" => user_archive["id"],
}
user_archive.merge!(topic_hash)
diff --git a/spec/jobs/export_user_archive_spec.rb b/spec/jobs/export_user_archive_spec.rb
index d7f13c3d79a..54055141c9a 100644
--- a/spec/jobs/export_user_archive_spec.rb
+++ b/spec/jobs/export_user_archive_spec.rb
@@ -214,6 +214,10 @@ RSpec.describe Jobs::ExportUserArchive do
expect(post1["reply_count"]).to eq(1)
expect(post2["reply_count"]).to eq(0)
+
+ expect(post1["post_id"]).to eq(normal_post.id)
+ expect(post2["post_id"]).to eq(subsubpost.id)
+ expect(post3["post_id"]).to eq(message_post.id)
end
it "can export a post from a deleted category" do