-
Notifications
You must be signed in to change notification settings - Fork 1
feat(task 2): add Statistics feature #36
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: mashroommole
Are you sure you want to change the base?
Conversation
Test Results23 tests 23 ✅ 2s ⏱️ Results for commit 45532c8. ♻️ This comment has been updated with latest results. |
|
|
||
| if (ex instanceof MethodArgumentNotValidException invalidArgumentException) { | ||
| errors = | ||
| invalidArgumentException.getBindingResult().getAllErrors().stream() |
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 looks like error extraction is the same, why then this IF is required?
|
|
||
| @RestControllerAdvice | ||
| public class ExceptionHandler { | ||
| @org.springframework.web.bind.annotation.ExceptionHandler({ |
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.
I believe this can be import shortened
| createdBy, | ||
| now, | ||
| now, | ||
| completed ? Instant.now() : null); |
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.
? now : null
|
|
||
| @JsonCreator | ||
| public static TodoStatisticsFormatEnum fromString(String value) { | ||
| for (TodoStatisticsFormatEnum format : TodoStatisticsFormatEnum.values()) { |
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.
Suggest to convert to Java Stream API
| } | ||
|
|
||
| @JsonValue | ||
| public String getValue() { |
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.
(y) great
| dto.setTotalTodos(total); | ||
| dto.setCompletedTodos(completed); | ||
| dto.setPendingTodos(pending); | ||
| dto.setUserStats(userStats); |
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 don't you consider creating a separate class for user stats data?
| request.setFormat(format); | ||
| } | ||
|
|
||
| private Map<String, List<Todos>> initiateTodosMap() { |
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.
Read out on web, there is a way in modern Java to handle this scenario without prior initialization.
There's a method in Map called putIfAbsent, where you pass default value if Key does not exist in map. Maybe that's suitable in this case.
| @TodoStatisticsValidDateRange | ||
| public class TodoStatisticsRequest { | ||
| @Parameter(example = "2025-09-01T10:30:00Z") | ||
| private Instant from; |
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.
Consider switching to LocalDateTime, in case you don't care about server time or timezone issue in this example
Summary:

Detailed:
