FIX: Add Type column to Flag Status CSV export (#30756)

This Type column is a special ":post" column on the
Flag Status report, so it did not show by default in
the CSV export of that report. This adds it so the
type of flag e.g. illegal, off topic, innapropriate
is shown in the CSV output.
This commit is contained in:
Martin Brennan 2025-01-14 13:31:55 +10:00 committed by GitHub
parent dc0bf90069
commit e9fb4131ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -218,6 +218,9 @@ module Jobs
elsif label[:type] == :topic
titles[label[:properties][:id]] = label[:title]
header << label[:properties][:id]
elsif label[:type] == :post
titles[label[:properties][:truncated_raw]] = label[:title]
header << label[:properties][:truncated_raw]
else
titles[label[:property]] = label[:title]
header << label[:property]

View File

@ -699,7 +699,7 @@ RSpec.describe Report do
context "with flags" do
let(:flagger) { Fabricate(:user, refresh_auto_groups: true) }
let(:post) { Fabricate(:post, user: flagger) }
let(:post) { Fabricate(:post, user: Fabricate(:user)) }
before { freeze_time }
@ -723,6 +723,26 @@ RSpec.describe Report do
expect(row[:resolution]).to eq("No action")
expect(row[:response_time]).to eq(nil)
end
it "exports the CSV of the report correctly" do
result =
PostActionCreator.new(flagger, post, PostActionType.types[:spam], message: "bad").perform
result.reviewable.perform(flagger, :agree_and_hide)
expect(result.success).to eq(true)
expect(report.data).to be_present
exporter = Jobs::ExportCsvFile.new
exporter.entity = "report"
exporter.extra = HashWithIndifferentAccess.new(name: "flags_status")
exporter.current_user = flagger
exported_csv = []
exporter.report_export { |entry| exported_csv << entry }
expect(exported_csv[0]).to eq(["Type", "Assigned", "Poster", "Flagger", "Resolution time"])
expect(exported_csv[1]).to eq(
["spam", flagger.username, post.user.username, flagger.username, "0.0"],
)
end
end
end