-
-
Notifications
You must be signed in to change notification settings - Fork 20
GH-1147 Make UserManager use UserRepository #1147
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the UserManager to use a repository pattern for data persistence, which is a great improvement. I've identified a few issues, including a critical bug that causes double database writes and a race condition during initial data loading. Additionally, there are opportunities to improve code clarity and maintainability by simplifying some logic and improving API design. The new integration tests are a good addition, but could be improved by removing console output.
eternalcore-core/src/main/java/com/eternalcode/core/user/UserManager.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/user/UserManager.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/user/UserManager.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/user/database/UserRepository.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/user/database/UserRepository.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/user/database/UserRepositoryOrmLite.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/test/java/com/eternalcode/core/user/BatchTest.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/test/java/com/eternalcode/core/user/UserBatchFetchTest.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/test/java/com/eternalcode/core/user/UserBatchFetchTest.java
Outdated
Show resolved
Hide resolved
sadcenter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
eternalcore-core/src/main/java/com/eternalcode/core/user/database/UserRepositoryOrmLite.java
Outdated
Show resolved
Hide resolved
…-manager-database
# Conflicts: # buildSrc/src/main/kotlin/Versions.kt # eternalcore-core/src/main/java/com/eternalcode/core/feature/fullserverbypass/FullServerBypassController.java # eternalcore-core/src/main/java/com/eternalcode/core/user/UserClientBukkitSettings.java
Rollczi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chyba tam testy wybuchają i takie tam
eternalcore-core/src/main/java/com/eternalcode/core/database/DatabaseConfig.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/database/DatabaseDriverType.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/user/UserController.java
Outdated
Show resolved
Hide resolved
…ation, remove unused methods, and streamline cache handling.
…uration, and streamline ORM functionality.
Rollczi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Część CR masz w commit - poprawki estetyczne - duplikacje i takie tam pierdoły.
Mam pewne pytania gdzie trochę nie jestem pewien intencji to zostawiam do twojej weryfikacji:
- jakieś rzeczy w user manager
- testy
eternalcore-core/src/main/java/com/eternalcode/core/user/database/UserRepositoryImpl.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/user/UserManager.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/main/java/com/eternalcode/core/user/UserManager.java
Outdated
Show resolved
Hide resolved
eternalcore-core/src/test/java/com/eternalcode/core/util/TestScheduler.java
Outdated
Show resolved
Hide resolved
…methods, and simplify `UserManager` logic.
…e no longer used.
| Optional<User> optionalUser = this.userManager.getUser(playerUUID); | ||
| User user = optionalUser.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Optional<User> optionalUser = this.userManager.getUser(playerUUID); | |
| User user = optionalUser.get(); | |
| User user = this.userManager.getUser(playerUUID).orElseThrow(); |
| UserManager userManager, | ||
| EventCaller eventCaller, | ||
| MsgToggleService msgToggleService | ||
| MsgToggleService msgToggleService, Server server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MsgToggleService msgToggleService, Server server | |
| MsgToggleService msgToggleService, | |
| Server server |
| UUID uuid = this.replies.getIfPresent(sender.getUniqueId()); | ||
|
|
||
| if (uuid == null) { | ||
| this.noticeService.player(sender.getUniqueId(), translation -> translation.msg().noReply()); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| Player target = this.server.getPlayer(uuid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| UUID uuid = this.replies.getIfPresent(sender.getUniqueId()); | |
| if (uuid == null) { | |
| this.noticeService.player(sender.getUniqueId(), translation -> translation.msg().noReply()); | |
| return; | |
| } | |
| Player target = this.server.getPlayer(uuid); | |
| UUID lastReplyUuid = this.replies.getIfPresent(sender.getUniqueId()); | |
| if (lastReplyUuid == null) { | |
| this.noticeService.player(sender.getUniqueId(), translation -> translation.msg().noReply()); | |
| return; | |
| } | |
| Player lastReply= this.server.getPlayer(lastReplyUuid ); |
Methods do not change so #1136 can be merged :>