Skip to content

Commit

Permalink
update csv info for timestamp and comment media
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeaty committed Nov 27, 2023
1 parent 46de21b commit 752a8eb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 38 deletions.
3 changes: 2 additions & 1 deletion server/src/core/server/locales/en-US/common.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ comment-counts-ratings-and-reviews =
staff-label = Staff
dsaReportCSV-timestamp = Timestamp
dsaReportCSV-timestamp = Timestamp (UTC)
dsaReportCSV-user = User
dsaReportCSV-action = Action
dsaReportCSV-details = Details
Expand All @@ -30,6 +30,7 @@ dsaReportCSV-additionalInfo = Additional info
dsaReportCSV-commentAuthor = Comment author
dsaReportCSV-commentBody = Comment body
dsaReportCSV-commentID = Comment ID
dsaReportCSV-commentMediaUrl = Comment media url
dsaReportCSV-changedStatus = Changed status
dsaReportCSV-addedNote = Added note
dsaReportCSV-madeDecision = Made decision
Expand Down
85 changes: 48 additions & 37 deletions server/src/core/server/services/dsaReports/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,51 +90,62 @@ export async function sendReportDownload(
}

csv.write([
translate(bundle, "Timestamp", "dsaReportCSV-timestamp"),
translate(bundle, "Timestamp (UTC)", "dsaReportCSV-timestamp"),
translate(bundle, "User", "dsaReportCSV-user"),
translate(bundle, "Action", "dsaReportCSV-action"),
translate(bundle, "Details", "dsaReportCSV-details"),
]);

// Set up default report info cell
let reportInfo = `${translate(
bundle,
"Reference ID",
"dsaReportCSV-referenceID"
)}: ${report.referenceID}\n${translate(
bundle,
"Legal detail",
"dsaReportCSV-legalDetail"
)}: ${report.lawBrokenDescription}\n${translate(
bundle,
"Additional info",
"dsaReportCSV-additionalInfo"
)}: ${report.additionalInformation}`;

// Add reported comment info to report info cell if available
if (reportedComment && report.status !== GQLDSAReportStatus.VOID) {
csv.write([
formatter.format(report.createdAt),
reporter?.username,
translate(bundle, "Report submitted", "dsaReportCSV-reportSubmitted"),
`${translate(bundle, "Reference ID", "dsaReportCSV-referenceID")}: ${
report.referenceID
}\n${translate(bundle, "Legal detail", "dsaReportCSV-legalDetail")}: ${
report.lawBrokenDescription
}\n${translate(
bundle,
"Additional info",
"dsaReportCSV-additionalInfo"
)}: ${report.additionalInformation}\n${translate(
reportInfo += `\n${translate(
bundle,
"Comment author",
"dsaReportCSV-commentAuthor"
)}: ${reportedCommentAuthorUsername}\n${translate(
bundle,
"Comment body",
"dsaReportCSV-commentBody"
)}: ${reportedComment.revisions[0].body}\n${translate(
bundle,
"Comment ID",
"dsaReportCSV-commentID"
)}: ${reportedComment.id}`;

// Add in comment media url if present
const commentMediaUrl = reportedComment.revisions[0].media?.url;
if (commentMediaUrl) {
reportInfo += `\n${translate(
bundle,
"Comment author",
"dsaReportCSV-commentAuthor"
)}: ${reportedCommentAuthorUsername}\nComment body: ${
reportedComment.revisions[0].body
}\n${translate(bundle, "Comment ID", "dsaReportCSV-commentID")}: ${
reportedComment.id
}`,
]);
} else {
csv.write([
formatter.format(report.createdAt),
reporter?.username,
translate(bundle, "Report submitted", "dsaReportCSV-reportSubmitted"),
`${translate(bundle, "Reference ID", "dsaReportCSV-referenceID")}: ${
report.referenceID
}\n${translate(bundle, "Legal detail", "dsaReportCSV-legalDetail")}: ${
report.lawBrokenDescription
}\n${translate(
bundle,
"Additional info",
"dsaReportCSV-additionalInfo"
)}: ${report.additionalInformation}`,
]);
"Comment media url",
"dsaReportCSV-commentMediaUrl"
)}: ${commentMediaUrl}`;
}
}

// Write report info cell data to CSV
csv.write([
formatter.format(report.createdAt),
reporter?.username,
translate(bundle, "Report submitted", "dsaReportCSV-reportSubmitted"),
reportInfo,
]);

if (report.history) {
const getStatusText = (status: GQLDSAReportStatus) => {
const mapping = {
Expand Down

0 comments on commit 752a8eb

Please sign in to comment.