Skip to content

Yana P. #4

Open
YanaP1312 wants to merge 7 commits into
HackYourAssignment:mainfrom
YanaP1312:main
Open

Yana P. #4
YanaP1312 wants to merge 7 commits into
HackYourAssignment:mainfrom
YanaP1312:main

Conversation

@YanaP1312

Copy link
Copy Markdown

This PR completes the core functionality and quality requirements for the Analytics API.
Implemented features include:

  • Full CRUD support for analytics records (create, list, filter, fetch by ID, replace, delete)
  • Server‑generated trace ID for each stored record
  • Time‑range filtering and additional useful filters (event type, event source, session ID)
  • Summary endpoint providing total records, counts per event type, and unique session count
  • Validation for incoming requests and consistent error handling
  • Refactored service layer with unit tests to ensure correct business logic behaviour
  • Clean, resource‑oriented URIs and appropriate HTTP methods/status codes

));

public List<AnalyticsRecord> getAll(){
return analyticsRecords;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This exposes the list so that the caller can mutate the list as a side-effect. Here a unmodifiable view on the list should be returned.


service.add(newRecord);

URI location = URI.create("records/" + newTraceId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this a relative path? Then relative to POST /records this would resolve to /records/records/{traceId}. It would be simpler to stick to the absolute path /records/{traceId}. Otherwise the path should become ../records/{traceId}.

I think best would be to let Spring generate the path like so:
URI location = ServletUriComponentsBuilder
.fromCurrentRequest()
.path("/{traceId}")
.buildAndExpand(newTraceId)
.toUri();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This compiled class file should not be committed into Git.


@ExceptionHandler(Exception.class)
public ResponseEntity<Map<String, String>> handleGeneralErrors(Exception ex) {
return ResponseEntity.badRequest().body(Map.of("error", ex.getMessage()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

General errors better give a HTTP response code like 500 instead of 400 Bad Request.

@composix

composix commented Jun 4, 2026

Copy link
Copy Markdown

Nice work! I also noticed the Swagger-UI on http://localhost:8081/swagger-ui/index.html which helps to test the API manually. To make trying out requests even more easy you could add some examples for the input parameters.

Comment thread task-1/mvnw

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This wrapper requires a configuration the download the right Maven en Java for building this project.

@composix composix left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

My comments give some minor improvements that are possible. But overal this PR is good to go!

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.

2 participants