Skip to content
This repository was archived by the owner on Jan 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/tasker.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ export async function getTasksAllowedForStations (roundDetails, randomness, meas
if (tasksAllowedForStations.has(m.stationId)) continue

const stationKey = await getStationKey(m.stationId)
const allowedTasks = seeker
.wHeap(stationKey, numberOfTasksToPick)
.map(({ key, ...t }) => (t))
const allowedTasks = numberOfTasksToPick
? seeker
.wHeap(stationKey, numberOfTasksToPick)
.map(({ key, ...t }) => (t))
: []
tasksAllowedForStations.set(m.stationId, allowedTasks)
}

Expand Down
13 changes: 13 additions & 0 deletions test/tasker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,17 @@ describe('tasksAllowedForStations', async () => {

assert.strictEqual(tasksAllowedForStations.get(VALID_MEASUREMENT.stationId)?.length, 2)
})

it('handles round with zero tasks', async () => {
/** @type {Measurement[]} */
const measurements = [VALID_MEASUREMENT]

const tasksAllowedForStations = await getTasksAllowedForStations(
{ retrievalTasks: [], maxTasksPerNode: 0 },
RANDOMNESS,
measurements
)

assert.strictEqual(tasksAllowedForStations.get(VALID_MEASUREMENT.stationId)?.length, 0)
})
})