-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @Jakubk15, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial feature for managing parcel locker capacity by allowing a configurable maximum number of parcels per locker. It integrates a pre-send check to ensure that parcels are not sent to full lockers, enhancing system stability and user experience. Players attempting to send parcels to an overloaded locker will receive an immediate notification, preventing failed deliveries and improving clarity. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
/gemini review |
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 successfully adds a configurable limit for the maximum number of parcels a locker can hold. The implementation is solid, introducing a check before a parcel is sent. I've identified a critical issue in GuiManager involving a race condition and a redundant database call, and I've provided a suggestion to fix it. Additionally, I've suggested a small improvement in the repository layer to handle potential integer overflows, making the implementation more robust. With these changes, the feature will be a great addition.
src/main/java/com/eternalcode/parcellockers/gui/GuiManager.java
Outdated
Show resolved
Hide resolved
src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepository.java
Show resolved
Hide resolved
src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryOrmLite.java
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.
Code Review
This pull request adds a feature to limit the maximum number of parcels per locker. The implementation looks good overall, introducing a new configuration option, a message for when the locker is full, and the logic to check the locker capacity before sending a parcel. I've found a critical bug in a database query that would prevent the feature from working correctly, and I've also suggested an improvement for handling potential errors in an asynchronous call to provide better feedback to the user. Please see my detailed comments.
src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryOrmLite.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.
Pull Request Overview
This PR adds a locker capacity limit feature to prevent parcels from being sent to full lockers. The implementation includes a configurable maximum parcels per locker setting and validates capacity before allowing parcel submissions.
- Added
countByDestinationLockermethod to count parcels in a specific locker - Implemented capacity check in
GuiManager.sendParcelwith user notification when locker is full - Added configuration option
maxParcelsPerLockerwith default value of 30
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryOrmLite.java | Implements database query to count parcels by destination locker |
| src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepository.java | Adds interface method for counting parcels by destination locker |
| src/main/java/com/eternalcode/parcellockers/locker/LockerManager.java | Adds isLockerFull method using the new count functionality and configuration |
| src/main/java/com/eternalcode/parcellockers/gui/GuiManager.java | Wraps parcel sending logic with capacity check and user notification |
| src/main/java/com/eternalcode/parcellockers/configuration/implementation/PluginConfig.java | Adds maxParcelsPerLocker configuration setting |
| src/main/java/com/eternalcode/parcellockers/configuration/implementation/MessageConfig.java | Adds lockerFull notification message |
| src/main/java/com/eternalcode/parcellockers/ParcelLockers.java | Updates dependency injection to pass required services to LockerManager and GuiManager |
| src/main/java/com/eternalcode/parcellockers/parcel/ParcelServiceImpl.java | Adds blank line (formatting only) |
| src/main/java/com/eternalcode/parcellockers/parcel/ParcelService.java | Adds blank line (formatting only) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/com/eternalcode/parcellockers/gui/GuiManager.java
Outdated
Show resolved
Hide resolved
src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryOrmLite.java
Outdated
Show resolved
Hide resolved
src/main/java/com/eternalcode/parcellockers/parcel/repository/ParcelRepositoryOrmLite.java
Show resolved
Hide resolved
…ParcelRepositoryOrmLite.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
|
||
| public CompletableFuture<Boolean> isLockerFull(UUID lockerUuid) { | ||
| return this.parcelRepository.countByDestinationLocker(lockerUuid) | ||
| .thenApply(count -> count >= this.config.settings.maxParcelsPerLocker); |
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.
maybe You can add option to set infinite number of parcels in the locer with value like -1 ? So this would be an option not a must.
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.
will add
| long count = dao.queryBuilder() | ||
| .where() | ||
| .eq(DESTINATION_LOCKER_COLUMN, destinationLocker) | ||
| .eq("status", ParcelStatus.DELIVERED) |
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.
Out of curiosity why only in this status and not on IN_PROGRESS ?
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.
Because we need to count parcels that have already arrived in the parcel locker.
No description provided.