generated from UdL-EPS-SoftArch-Igualada/spring-template
-
Notifications
You must be signed in to change notification settings - Fork 14
feat(match-assignment): add atomic batch referee assignment by round #76
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
Merged
pol-rivero
merged 4 commits into
UdL-EPS-SoftArch-Igualada:main
from
Ferranicu:feat/issue-66-batch-referee-assignment
Mar 4, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
94e48a9
feat(match-assignment): add atomic batch referee assignment by round
Ferranicu 09fe96a
fix(match-assignment): address PR review findings for batch assignment
Ferranicu 9a61654
fix(match-assignment): address copilot robustness and flaky test notes
Ferranicu b601069
fix(sonarqube): fix sonarqube errors
Ferranicu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package cat.udl.eps.softarch.fll.controller.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record BatchMatchAssignmentItemRequest( | ||
| @NotBlank String matchId, | ||
| @NotBlank String refereeId | ||
| ) {} |
7 changes: 7 additions & 0 deletions
7
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentItemResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package cat.udl.eps.softarch.fll.controller.dto; | ||
|
|
||
| public record BatchMatchAssignmentItemResponse( | ||
| String matchId, | ||
| String refereeId, | ||
| String status | ||
| ) {} |
12 changes: 12 additions & 0 deletions
12
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package cat.udl.eps.softarch.fll.controller.dto; | ||
|
|
||
| import java.util.List; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotEmpty; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record BatchMatchAssignmentRequest( | ||
| @NotBlank String roundId, | ||
| @NotEmpty List<@NotNull @Valid BatchMatchAssignmentItemRequest> assignments | ||
| ) {} |
16 changes: 16 additions & 0 deletions
16
src/main/java/cat/udl/eps/softarch/fll/controller/dto/BatchMatchAssignmentResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package cat.udl.eps.softarch.fll.controller.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record BatchMatchAssignmentResponse( | ||
| String roundId, | ||
| String status, | ||
| int processed, | ||
| List<BatchMatchAssignmentItemResponse> assignments | ||
| ) { | ||
| public BatchMatchAssignmentResponse { | ||
| if (assignments == null || processed != assignments.size()) { | ||
| throw new IllegalArgumentException("processed must match assignments size"); | ||
| } | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentErrorCode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 25 additions & 5 deletions
30
src/main/java/cat/udl/eps/softarch/fll/exception/MatchAssignmentExceptionHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,43 @@ | ||
| package cat.udl.eps.softarch.fll.exception; | ||
|
|
||
| import java.time.Instant; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.ExceptionHandler; | ||
| import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
|
|
||
| @RestControllerAdvice | ||
| public class MatchAssignmentExceptionHandler { | ||
|
|
||
| @ExceptionHandler(MatchAssignmentException.class) | ||
| public ResponseEntity<ErrorResponse> handleMatchAssignmentException(MatchAssignmentException ex) { | ||
| public ResponseEntity<ErrorResponse> handleMatchAssignmentException( | ||
| MatchAssignmentException ex, | ||
| HttpServletRequest request) { | ||
| HttpStatus status = switch (ex.getErrorCode()) { | ||
| case MATCH_NOT_FOUND, REFEREE_NOT_FOUND -> HttpStatus.NOT_FOUND; | ||
| case AVAILABILITY_CONFLICT, MATCH_ALREADY_HAS_REFEREE -> HttpStatus.CONFLICT; | ||
| case ROUND_NOT_FOUND, MATCH_NOT_FOUND, REFEREE_NOT_FOUND -> HttpStatus.NOT_FOUND; | ||
| case AVAILABILITY_CONFLICT, MATCH_ALREADY_HAS_REFEREE, DUPLICATE_MATCH_IN_BATCH -> HttpStatus.CONFLICT; | ||
| case INVALID_ROLE, INVALID_MATCH_STATE, INVALID_ID_FORMAT -> HttpStatus.UNPROCESSABLE_CONTENT; | ||
| }; | ||
| ErrorResponse body = new ErrorResponse(ex.getErrorCode().name(), ex.getMessage()); | ||
|
|
||
| BatchErrorDetails details = ex.hasBatchDetails() | ||
| ? new BatchErrorDetails(ex.getIndex(), ex.getMatchId(), ex.getRefereeId(), ex.getErrorCode().name()) | ||
| : null; | ||
| ErrorResponse body = new ErrorResponse( | ||
| ex.hasBatchDetails() ? "BATCH_ASSIGNMENT_FAILED" : ex.getErrorCode().name(), | ||
| ex.hasBatchDetails() ? "Assignment failed at index " + ex.getIndex() : ex.getMessage(), | ||
| Instant.now().toString(), | ||
| request.getRequestURI(), | ||
| details); | ||
| return ResponseEntity.status(status).body(body); | ||
| } | ||
|
|
||
| public record ErrorResponse(String error, String message) {} | ||
| public record ErrorResponse( | ||
| String error, | ||
| String message, | ||
| String timestamp, | ||
| String path, | ||
| BatchErrorDetails details) {} | ||
|
|
||
| public record BatchErrorDetails(Integer index, String matchId, String refereeId, String cause) {} | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.