-
-
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?
Changes from all commits
d454560
a082ab8
0f7f46e
9395829
f942ddf
9d61b1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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; | ||
| }); | ||
| } | ||
|
|
||
| private CompletableFuture<PageResult<Parcel>> fetchByPaged(UUID key, Page page, String column) { | ||
| return this.action( | ||
| ParcelTable.class, dao -> { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.