-
Notifications
You must be signed in to change notification settings - Fork 1
feat(task-2): Create the "Statistics" Feature #34
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: margarita-pashnina
Are you sure you want to change the base?
Conversation
| int completedTodos, | ||
| int pendingTodos, | ||
| Map<String, Integer> userStats, | ||
| Optional<Map<String, List<StatisticsTodo>>> todos) {} |
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.
Unusual formatting. If you use IDEA you can press Ctrl+Llt+L or check "Reformat code" in commit options.
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.
Spotless check on build fails otherwise, maybe it's supposed to look like this
BagumEpmak
left a comment
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.
| return ResponseEntity.ok(statisticsService.getStatisticsSummary(from, to, format)); | ||
| } | ||
|
|
||
| @ExceptionHandler(ConstraintViolationException.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.
@margarita-pashnina I would suggest to extract exception handlers to a separate common class. As these ConstraintViolationException can be thrown everywhere across the app. Imagine you have 10 controllers, but the behaviour shall be the same for all throws, I assume
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.
done
| public class StatisticsFormatValidator implements ConstraintValidator<StatisticsFormat, String> { | ||
| @Override | ||
| public boolean isValid(String value, ConstraintValidatorContext context) { | ||
| return value.equals("summary") || value.equals("detailed"); |
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.
A small trick. It's better to compare as "summary".equals(value), so that there never is NullPointerException thrown
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.
good to know, thanks, fixed
|
|
||
| Map<String, Integer> userStats = getUserStats(result); | ||
|
|
||
| if (format.equals("summary")) { |
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.
Another idea, how about converting format from plain String to an ENUM? As it looks like only known type of formats are supported and API consumer cannot pass something else in a format value.
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.
done
| .and(countTodosPerUser) | ||
| .as("userStats"); | ||
|
|
||
| FacetOperation detailsFacet = |
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.
Here I would split this method into two, for summary and detailed data to be returned. If I understood correctly, based on format type we return only one of the facetOperation results, mething that those initializations can be done and hidden WITHIN an IF or in a separate methods
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.
done






No description provided.