Closed paulmis closed 2 years ago
requested review from @rstular and @ddinucujianu
marked this merge request as draft
marked this merge request as ready
E2E in progress, but please review already.
In GitLab by @rstular on Mar 14, 2022, 14:33
Commented on server/src/main/java/server/services/GameService.java line 94
This should close the user's SSE listener as well.
In GitLab by @rstular on Mar 14, 2022, 14:33
Commented on server/src/main/java/server/database/repositories/game/GameRepository.java line 36
You could replace this with Optional<Game> findByPlayers_User_IdEqualsAndStatusAndPlayers_Abandoned(UUID id, GameStatus status, boolean abandoned);
instead.
In GitLab by @rstular on Mar 14, 2022, 14:33
Commented on server/src/main/java/server/database/entities/game/GamePlayer.java line 40
The findByPlayers_User_IdEqualsAndStatus
method in GameRepository
should be changed to findByPlayers_User_IdEqualsAndStatusAndPlayers_Abandoned
.
As of now, all abandoned players won't be detected as such, as the old method fails to account for the abandoned
GamePlayer
field.
In GitLab by @rstular on Mar 14, 2022, 14:33
Commented on server/src/main/java/server/database/entities/game/Game.java line 178
This can be replaced with .orElseThrow(LastPlayerRemovedException::new)
, and the subsequent null check can be removed.
Can you link the docs on how that's done?
Yeah I did initially but this is literally longer than the line character limit and requires 2 arguments that are invariable, so I think this is better.
It can't because then the host isn't removed.
I think we're using that one for lobbies only, and players can't abandon lobbies (they are completely removed instead). I think it'd be better to rename that function instead.
In GitLab by @rstular on Mar 14, 2022, 15:00
Commented on server/src/main/java/server/services/GameService.java line 94
In the SSEManager, first get(UUID userId)
the emitter for the user, call .complete()
on the emitter, and then call SSEManager.unregister(UUID userId)
.
I think it would make sense to add a convenience method for that to the SSEManager
class.
In GitLab by @rstular on Mar 14, 2022, 15:00
Commented on server/src/main/java/server/database/repositories/game/GameRepository.java line 36
Fair enough
In GitLab by @rstular on Mar 14, 2022, 15:03
Commented on server/src/main/java/server/database/entities/game/GamePlayer.java line 40
It's used here as well, this usage probably needs to account for abandoned
status.
In GitLab by @rstular on Mar 14, 2022, 15:04
Commented on server/src/main/java/server/database/entities/game/Game.java line 178
I see, my bad.
Changed the function in SSEManager
and added description to findByPlayers_User_IdEqualsAndStatus
.
Added.
added 1 commit
added 71 commits
dev
In GitLab by @rstular on Mar 16, 2022, 06:01
As for the "get new container" instructions, I think using docker-compose down
is more appropriate, killing seems a bit harsh (and unnecessary, as down
both stops and removes containers and networks).
In GitLab by @rstular on Mar 16, 2022, 06:02
resolved all threads
In GitLab by @rstular on Mar 16, 2022, 06:03
resolved all threads
Changed.
In GitLab by @rstular on Mar 16, 2022, 06:12
Commented on server/src/test/java/server/api/LobbyControllerTest.java line 345
What exactly is being tested here?
Apparently nothing :shrug:
In GitLab by @rstular on Mar 16, 2022, 06:25
Commented on server/src/test/java/server/api/LobbyControllerTest.java line 345
Yeet
Fixed.
In GitLab by @ddinucujianu on Mar 17, 2022, 02:03
Commented on server/src/main/java/server/services/GameService.java line 97
Could this also announce every player in the game that somebody left? Like just an event with playerLeft or something like that? Would work nicely to update the top bar leaderboard quickly or even display a short message.
In GitLab by @gpezzali on Mar 17, 2022, 11:36
Commented on docker-compose.yml line 11
Why is there a minus sign here and not in application.yml
?
Same format, different parsing rules. docker-compose
's default argument is preceded by a -
.
Added to the ongoing leave endpoint.
In GitLab by @ddinucujianu on Mar 17, 2022, 13:56
Commented on server/src/main/java/server/services/GameService.java line 111
I don't think this can work with the current set-up on the client can you do something like:
SseEmitter.SseEventBuilder event = SseEmitter.event()
.id("1")
.name("playerLeft").data(user.getId());
game.getEmitters().sendAll(event);
Putting the player id in the data is optional cause we can just query the whole database but yeah.
In GitLab by @gpezzali on Mar 17, 2022, 14:37
Commented on server/src/main/java/server/api/GameController.java line 45
Every other lobby/game-related endpoint takes the game id as path variable, it would be nice to keep them coherent
The game can be derived from the user. This has the benefit of having automatic verification (i.e. no need to check if the player is in the specified game).
In GitLab by @gpezzali on Mar 17, 2022, 14:56
Commented on server/src/test/java/server/services/GameServiceTest.java line 70
Should use getUUID
In GitLab by @gpezzali on Mar 17, 2022, 14:59
Commented on server/src/test/java/server/services/LobbyServiceTest.java line 46
This should use TestHelpers::getUUID
too
changed this line in version 10 of the diff
Changed.
changed this line in version 11 of the diff
added 1 commit
In GitLab by @ddinucujianu on Mar 17, 2022, 15:06
Looks good
In GitLab by @ddinucujianu on Mar 17, 2022, 15:07
approved this merge request
Merges 123-expose-leave-game-endpoint -> dev
Closes #123. Somehow there were lots of test for this.
This also changes the local
postgres
port to 5555 which should fix some issues some of you had when already having the db installed. Remember to rebuild the container with: