Skip to content

Conversation

@MashroomMole
Copy link
Collaborator

@MashroomMole MashroomMole commented Sep 5, 2025

Summary:
image

Detailed:
image

@github-actions
Copy link

github-actions bot commented Sep 5, 2025

Test Results

23 tests   23 ✅  2s ⏱️
11 suites   0 💤
11 files     0 ❌

Results for commit 45532c8.

♻️ This comment has been updated with latest results.

@MashroomMole MashroomMole marked this pull request as draft September 5, 2025 09:07
@MashroomMole MashroomMole changed the title Task 2: add Statistics feature feat(task 1): add Statistics feature Sep 5, 2025
@MashroomMole MashroomMole changed the title feat(task 1): add Statistics feature feat(task 2): add Statistics feature Sep 5, 2025
@MashroomMole MashroomMole changed the base branch from main to mashroommole September 5, 2025 13:41
@MashroomMole MashroomMole marked this pull request as ready for review September 5, 2025 13:52
@MashroomMole MashroomMole changed the base branch from mashroommole to main September 5, 2025 13:57
@MashroomMole MashroomMole changed the base branch from main to mashroommole September 5, 2025 13:58

if (ex instanceof MethodArgumentNotValidException invalidArgumentException) {
errors =
invalidArgumentException.getBindingResult().getAllErrors().stream()
Copy link
Collaborator

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({
Copy link
Collaborator

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);
Copy link
Collaborator

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()) {
Copy link
Collaborator

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() {
Copy link
Collaborator

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);
Copy link
Collaborator

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() {
Copy link
Collaborator

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;
Copy link
Collaborator

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

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