mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-21 10:15:04 +02:00
Start queued jobs in list order, whether pinned or "Any <model>" (#3200)
This commit is contained in:
@@ -1231,19 +1231,17 @@ export function PrintModal({
|
||||
}
|
||||
}
|
||||
|
||||
const asapInsertionCounts = new Map<string, number>();
|
||||
// ASAP items go to the top of the queue in the order this submit creates
|
||||
// them. One counter for the whole submit: positions are a single sequence
|
||||
// across every printer and model (#3200), so a per-printer counter would put
|
||||
// each printer's first item at position 1 and shuffle them.
|
||||
let asapInserted = 0;
|
||||
|
||||
const applyAsapInsertion = (
|
||||
queueData: PrintQueueItemCreate,
|
||||
printerId: number | null,
|
||||
itemCount = 1,
|
||||
) => {
|
||||
const applyAsapInsertion = (queueData: PrintQueueItemCreate, itemCount = 1) => {
|
||||
if (scheduleOptions.scheduleType !== 'asap') return;
|
||||
const scopeKey = printerId !== null ? `printer:${printerId}` : 'unassigned';
|
||||
const insertPosition = (asapInsertionCounts.get(scopeKey) ?? 0) + 1;
|
||||
queueData.insert_at_top = true;
|
||||
queueData.insert_position = insertPosition;
|
||||
asapInsertionCounts.set(scopeKey, insertPosition + itemCount - 1);
|
||||
queueData.insert_position = asapInserted + 1;
|
||||
asapInserted += itemCount;
|
||||
};
|
||||
|
||||
// Common queue data for create and edit modes
|
||||
@@ -1330,7 +1328,7 @@ export function PrintModal({
|
||||
const queueData = getQueueData(null, plateId);
|
||||
const plateQuantity = quantityForPlate(plateId);
|
||||
if (plateQuantity > 1) queueData.quantity = plateQuantity;
|
||||
applyAsapInsertion(queueData, null, plateQuantity);
|
||||
applyAsapInsertion(queueData, plateQuantity);
|
||||
await addToQueueMutation.mutateAsync(queueData);
|
||||
}
|
||||
results.success++;
|
||||
@@ -1400,7 +1398,7 @@ export function PrintModal({
|
||||
const queueData = getQueueData(printerId, plateId);
|
||||
const plateQuantity = quantityForPlate(plateId);
|
||||
if (plateQuantity > 1) queueData.quantity = plateQuantity;
|
||||
applyAsapInsertion(queueData, printerId, plateQuantity);
|
||||
applyAsapInsertion(queueData, plateQuantity);
|
||||
// Apply stagger offset for groups after the first
|
||||
if (useStagger) {
|
||||
const groupIndex = Math.floor(i / scheduleOptions.staggerGroupSize);
|
||||
|
||||
Reference in New Issue
Block a user