Skip to content

Conversation

@margarita-pashnina
Copy link
Collaborator

No description provided.

@margarita-pashnina margarita-pashnina changed the base branch from main to margarita-pashnina August 28, 2025 06:39
@github-actions
Copy link

github-actions bot commented Aug 28, 2025

Test Results

17 tests  +5   17 ✅ +5   2s ⏱️ -1s
10 suites +1    0 💤 ±0 
10 files   +1    0 ❌ ±0 

Results for commit 4611cd5. ± Comparison against base commit babbd85.

♻️ This comment has been updated with latest results.

int completedTodos,
int pendingTodos,
Map<String, Integer> userStats,
Optional<Map<String, List<StatisticsTodo>>> todos) {}
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Copy link
Collaborator

@BagumEpmak BagumEpmak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix these issues first:

  1. Response for summary
    response for summary should not include "todos"
image
  1. Swagger definition
    Current swagger page:
image

I would expect something like this:
image

@margarita-pashnina
Copy link
Collaborator Author

Please fix these issues first:

1. Response for summary
   response for summary should not include "todos"
image
2. Swagger definition
   Current swagger page:
image

I would expect something like this: image

fixed

return ResponseEntity.ok(statisticsService.getStatisticsSummary(from, to, format));
}

@ExceptionHandler(ConstraintViolationException.class)
Copy link
Collaborator

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

Copy link
Collaborator Author

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

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

Copy link
Collaborator Author

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

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.

Copy link
Collaborator Author

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

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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.

4 participants