Repository navigation
GH-143 Add 'max parcels per locker' option #143
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d454560
Add 'max parcels per locker' option
Jakubk15 a082ab8
Update src/main/java/com/eternalcode/parcellockers/parcel/repository/…
Jakubk15 0f7f46e
adjust to copilot's suggestions
Jakubk15 9395829
thenRun -> thenAccept
Jakubk15 f942ddf
[ci skip] delete redundant comment
Jakubk15 9d61b1b
Adjust to Mike's suggestion, simplify code, bump MC version to 1.21.10
Jakubk15 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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import com.eternalcode.parcellockers.database.DatabaseManager; | ||
| import com.eternalcode.parcellockers.database.wrapper.AbstractRepositoryOrmLite; | ||
| import com.eternalcode.parcellockers.parcel.Parcel; | ||
| import com.eternalcode.parcellockers.parcel.ParcelStatus; | ||
| import com.eternalcode.parcellockers.shared.Page; | ||
| import com.eternalcode.parcellockers.shared.PageResult; | ||
| import com.j256.ormlite.table.TableUtils; | ||
|
|
@@ -18,6 +19,7 @@ public class ParcelRepositoryOrmLite extends AbstractRepositoryOrmLite implement | |
|
|
||
| private static final String RECEIVER_COLUMN = "receiver"; | ||
| private static final String SENDER_COLUMN = "sender"; | ||
| private static final String DESTINATION_LOCKER_COLUMN = "destination_locker"; | ||
|
|
||
| public ParcelRepositoryOrmLite(DatabaseManager databaseManager, Scheduler scheduler) { | ||
| super(databaseManager, scheduler); | ||
|
|
@@ -70,6 +72,18 @@ public CompletableFuture<PageResult<Parcel>> fetchByReceiver(UUID receiver, Page | |
| return this.fetchByPaged(receiver, page, RECEIVER_COLUMN); | ||
| } | ||
|
|
||
| @Override | ||
| public CompletableFuture<Integer> countByDestinationLocker(UUID destinationLocker) { | ||
| return this.action(ParcelTable.class, dao -> { | ||
| long count = dao.queryBuilder() | ||
| .where() | ||
| .eq(DESTINATION_LOCKER_COLUMN, destinationLocker) | ||
| .eq("status", ParcelStatus.DELIVERED) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity why only in this status and not on IN_PROGRESS ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we need to count parcels that have already arrived in the parcel locker. |
||
| .countOf(); | ||
| return (int) count; | ||
| }); | ||
|
Jakubk15 marked this conversation as resolved.
|
||
| } | ||
|
Jakubk15 marked this conversation as resolved.
|
||
|
|
||
| private CompletableFuture<PageResult<Parcel>> fetchByPaged(UUID key, Page page, String column) { | ||
| return this.action( | ||
| ParcelTable.class, dao -> { | ||
|
|
||
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.