-
-
Couldn't load subscription status.
- Fork 21
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
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
|
|
||
| @Override | ||
| public CompletableFuture<Collection<User>> fetchUsersBatch(int batchSize) { | ||
| return CompletableFuture.supplyAsync(() -> { |
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.
I think you should supply a custom executor, since you are already using one in all AbstractRepositoryOrmLite methods
…-manager-database
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
| + "database type " | ||
| + "to be used."}) | ||
| public DatabaseDriverType databaseType = DatabaseDriverType.SQLITE; | ||
| public DatabaseDriverType databaseType = DatabaseDriverType.MYSQL; |
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.
hm czemu tak? jak w testach coś nie gra to settuj fielda jest public
| SQLITE(SQLITE_DRIVER, SQLITE_JDBC_URL); | ||
| SQLITE(SQLITE_DRIVER, SQLITE_JDBC_URL), | ||
|
|
||
| H2_TEST(H2_DRIVER, "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=MYSQL"); |
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.
raczej bym unikał dodawania kawałków kodu które są tylko dla testów, jaki tutaj był problem? może da się to lepiej rozwiązać?
|
|
||
| @EventHandler | ||
| public void onJoin(PlayerJoinEvent event) { | ||
| this.userManager.fetchUser(event.getPlayer().getUniqueId()); |
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.
a jak ci userzy są tworzeni?
Methods do not change so #1136 can be merged :>