-
Notifications
You must be signed in to change notification settings - Fork 1
Kirill topchy ctco task/2 #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: KirillTopchyCtco
Are you sure you want to change the base?
Conversation
…rillTopchyCtco-task/1
…rillTopchyCtco-task/1
…rillTopchyCtco-task/1
Test Results0 tests 0 ✅ 0s ⏱️ 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<>(); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
As i do not have access to Docker, I have changed tests to work with local mongo db instance on port 27017