Skip to content

Conversation

@KirillTopchyCtco
Copy link
Collaborator

As i do not have access to Docker, I have changed tests to work with local mongo db instance on port 27017

@github-actions
Copy link

github-actions bot commented Dec 16, 2025

Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 7e1f418.

♻️ This comment has been updated with latest results.

public static Map<String, Integer> extractUserStats(Document root) {
if (root == null) return Map.of();
List<Document> userStatsDocs = getArray(root, "userStats");
Map<String, Integer> map = new LinkedHashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is better to create map using stream on userStatsDocs

@ApiResponse(responseCode = "500", description = "Internal server error", content = @Content(schema = @Schema(implementation = StatisticsErrorResponse.class)))
}
)
public ResponseEntity<?> getStatistics(StatisticsRequest request) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why "?"? Is response class unknown?


import java.util.List;

@RestControllerAdvice(assignableTypes = StatisticsController.class)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not global exception handler but only for statistic controller? I see that you have specific return type for this, but it is better to come up with universal error class structure, which will be used by all controllers

public class StatisticsQueryBuilder {
public StatisticsQuery build(StatisticsRequest request) {
List<String> errors = new ArrayList<>();
LocalDate from = parseDate("from", request.from(), errors);
Copy link
Collaborator

Choose a reason for hiding this comment

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

As an option you might use validation framework and that use @Valid in controller

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.

3 participants