Skip to content

Fix CSV downloads for challenge reports#50

Merged
jmgasper merged 3 commits intomasterfrom
develop
Feb 25, 2026
Merged

Fix CSV downloads for challenge reports#50
jmgasper merged 3 commits intomasterfrom
develop

Conversation

@jmgasper
Copy link
Collaborator

No description provided.

@jmgasper jmgasper merged commit 7b310ce into master Feb 25, 2026
5 of 6 checks passed
fs.writeFileSync(outputPath, `${lines.join("\n")}\n`, "utf8");
}

function toNumberOrZero(value) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The toNumberOrZero function is introduced to handle conversion of values to numbers with a fallback to zero. Ensure that this function is used consistently throughout the codebase wherever similar conversions are needed to maintain uniformity and prevent potential errors from inconsistent handling.

toNumberOrZero(row["user_payment.net_amount"]);
}

const aggregatedRows = Array.from(aggregatedByUser.values())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 performance]
The use of Array.from(aggregatedByUser.values()) followed by map and sort is correct but could be optimized. Consider chaining these operations directly on the Map to avoid creating an intermediate array, which could improve performance slightly, especially with large datasets.

} from "./dtos/submission-links.dto";

@ApiTags("Challenges Reports")
@ApiProduces("application/json", "text/csv")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The @ApiProduces decorator specifies both application/json and text/csv. Ensure that the CsvResponseInterceptor correctly handles the content negotiation between these types, as it might affect the response format expected by clients.


@ApiTags("Challenges Reports")
@ApiProduces("application/json", "text/csv")
@UseInterceptors(CsvResponseInterceptor)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ design]
The CsvResponseInterceptor is applied globally to the controller. Verify that all endpoints within this controller are intended to support CSV responses, as this might introduce unexpected behavior for endpoints not designed to return CSV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant