-
Notifications
You must be signed in to change notification settings - Fork 1
Warlockxins task 2 #44
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: warlockxins
Are you sure you want to change the base?
Conversation
src/main/java/lv/ctco/springboottemplate/config/ResponseFormatConverter.java
Outdated
Show resolved
Hide resolved
src/main/java/lv/ctco/springboottemplate/features/statistics/StatisticsService.java
Show resolved
Hide resolved
Test Results18 tests 18 ✅ 1s ⏱️ Results for commit 9e57c09. ♻️ This comment has been updated with latest results. |
src/main/java/lv/ctco/springboottemplate/features/statistics/StatisticsController.java
Outdated
Show resolved
Hide resolved
src/main/java/lv/ctco/springboottemplate/features/statistics/StatisticsController.java
Outdated
Show resolved
Hide resolved
src/main/java/lv/ctco/springboottemplate/features/statistics/StatisticsController.java
Outdated
Show resolved
Hide resolved
|
|
||
| if (from != null && to != null) { | ||
| criteria = Criteria.where("createdAt").gte(from).lte(to); | ||
| criteria.lte(to); |
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.
lte is called twice
src/main/java/lv/ctco/springboottemplate/features/statistics/TodoStatsRepository.java
Show resolved
Hide resolved
| this.mongoTemplate = mongoTemplate; | ||
| } | ||
|
|
||
| Aggregation getSummaryStatsAggregation(ResponseFormat format, Instant from, Instant to) { |
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.
IMO it should be a private method
| } else if (to != null) { | ||
| criteria = Criteria.where("createdAt").lte(to); | ||
| } | ||
|
|
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.
Looks like lines 23-32 should be:
Criteria criteria = new Criteria();
if (from != null) {
criteria.gte(from);
}
if (to != null) {
criteria.lte(to);
}
| Criteria criteria = new Criteria(); | ||
|
|
||
| if (from != null && to != null) { | ||
| criteria = Criteria.where("createdAt").gte(from).lte(to); |
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's better to have string constans or enums for field names
| return Aggregation.newAggregation(matchStage, countsFacet, project); | ||
| } | ||
|
|
||
| Long extractLong(Document doc, String key) { |
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.
should be private
| Map<String, Long> userStats = | ||
| userStatsList.stream() | ||
| .collect( | ||
| java.util.stream.Collectors.toMap( |
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 do you need package name (java.util.stream) as a prefix?
| userStatsList.stream() | ||
| .collect( | ||
| java.util.stream.Collectors.toMap( | ||
| d -> d.getString("_id"), d -> ((Number) d.get("count")).longValue())); |
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.
extractLong?
This was fun, and was able to experiment with more global config with spring.