Issue: 002

Fix unassigned item pagination across assigned pages

- Keep unassigned items off earlier assigned pages
- Begin unassigned items after the last assigned slot
- Continue remaining unassigned items on subsequent pages
- Prevent unassigned item duplication between pages
- Preserve existing assigned item slot placement
This commit is contained in:
BigPappa committed 2026-08-09 05:58:39 -05:00
1 parent cb75e2bca7
commit b6d376a2f9
2 files changed
+37 -77

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@
<groupId>com.rsscripting</groupId>
<artifactId>RS-Warehouse</artifactId>
<name>RS-Warehouse</name>
<version>1.1.0</version>
<version>1.2.0</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
@@ -19,6 +19,7 @@ public class ItemsPagination {
int highestAssignedPage = -1;
int unassigned = 0;
int lastPageHighestSlot = 8;
for (WarehouseItem item : items) {
@@ -46,13 +47,17 @@ public class ItemsPagination {
}
int consumed = 0;
if (highestAssignedPage < 0) {
for (int assignedPage = 0;
assignedPage <= highestAssignedPage;
assignedPage++) {
int pages =
(unassigned + 44) / 45;
int highestSlot = 8;
return Math.max(
0,
pages - 1
);
}
for (WarehouseItem item : items) {
@@ -61,12 +66,12 @@ public class ItemsPagination {
&&
item.slot() != null
&&
item.page() == assignedPage + 1
item.page() == highestAssignedPage + 1
) {
highestSlot =
lastPageHighestSlot =
Math.max(
highestSlot,
lastPageHighestSlot,
item.slot()
);
@@ -74,24 +79,20 @@ public class ItemsPagination {
}
consumed +=
int availableOnLastAssignedPage =
Math.max(
0,
53 - highestSlot
53 - lastPageHighestSlot
);
}
consumed =
Math.min(
consumed,
unassigned
int remainingUnassigned =
Math.max(
0,
unassigned - availableOnLastAssignedPage
);
unassigned -= consumed;
int overflowPages =
(unassigned + 44) / 45;
(remainingUnassigned + 44) / 45;
return Math.max(
0,
@@ -175,38 +176,9 @@ public class ItemsPagination {
}
/*
* Figure out how many unassigned items have
* already been consumed by previous assigned pages.
* Unassigned items begin only on the last assigned page.
*/
int consumed = 0;
for (int previousPage = 0;
previousPage < page;
previousPage++) {
int previousHighestSlot = 8;
for (WarehouseItem item : assigned) {
if (item.page() == (previousPage + 1)) {
previousHighestSlot =
Math.max(
previousHighestSlot,
item.slot()
);
}
}
consumed +=
Math.max(
0,
53 - previousHighestSlot
);
}
if (page == highestAssignedPage) {
int remainingSlots =
Math.max(
@@ -214,20 +186,17 @@ public class ItemsPagination {
53 - highestSlot
);
while (
remainingSlots > 0
&&
consumed < unassigned.size()
) {
for (int i = 0;
i < remainingSlots && i < unassigned.size();
i++) {
results.add(
unassigned.get(
consumed
i
)
);
consumed++;
remainingSlots--;
}
}
@@ -235,21 +204,18 @@ public class ItemsPagination {
}
int consumed = 0;
for (int assignedPage = 0;
assignedPage <= highestAssignedPage;
assignedPage++) {
int highestSlot = 8;
/*
* Overflow pages contain only unassigned items.
*/
int lastPageHighestSlot = 8;
for (WarehouseItem item : assigned) {
if (item.page() == assignedPage + 1) {
if (item.page() == highestAssignedPage + 1) {
highestSlot =
lastPageHighestSlot =
Math.max(
highestSlot,
lastPageHighestSlot,
item.slot()
);
@@ -257,24 +223,18 @@ public class ItemsPagination {
}
consumed +=
int consumed =
Math.max(
0,
53 - highestSlot
53 - lastPageHighestSlot
);
}
consumed =
Math.min(
consumed,
unassigned.size()
);
/*
* Overflow pages
*/
int overflowPage =
page
- highestAssignedPage