Skip to content
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

fix(app): don't doublecount labware on modules #6246

Merged
merged 2 commits into from
Aug 3, 2020
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
40 changes: 40 additions & 0 deletions app/src/calibration/labware/__tests__/selectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,45 @@ describe('labware calibration selectors', () => {
},
])
})

it('does not aggregate labware across differing parents', () => {
getLabware.mockReturnValue([
({
type: wellPlate96Def.parameters.loadName,
definition: wellPlate96Def,
slot: '2',
}: $Shape<ProtocolLabware>),
({
type: wellPlate96Def.parameters.loadName,
definition: wellPlate96Def,
slot: '3',
}: $Shape<ProtocolLabware>),
])

getModulesBySlot.mockImplementation(calledState => {
return {
'3': {
model: 'magneticModuleV1',
slot: '3',
_id: 1945365648,
},
}
})

expect(Selectors.getProtocolLabwareList(state, robotName)).toEqual([
{
displayName: wellPlate96Def.metadata.displayName,
parentDisplayName: null,
quantity: 1,
calibration: null,
},
{
displayName: wellPlate96Def.metadata.displayName,
parentDisplayName: 'Magnetic Module GEN1',
quantity: 1,
calibration: null,
},
])
})
})
})
17 changes: 13 additions & 4 deletions app/src/calibration/labware/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,25 @@ export const getProtocolLabwareList: (
const { definition: def, loadName, namespace, version, parent } = lw
const displayName = def ? getLabwareDisplayName(def) : loadName
const parentDisplayName = parent ? getModuleDisplayName(parent) : null
const matchesLabwareIdentity = target =>
const matchesLabwareIdentityForQuantity = target =>
target.loadName === loadName &&
target.namespace === namespace &&
target.version === version &&
(parent === null || target.parent === parent)
target.parent === parent

const quantity = baseLabwareList.filter(matchesLabwareIdentityForQuantity)
.length

const quantity = baseLabwareList.filter(matchesLabwareIdentity).length
const matchesLabwareIdentityForCalibration = target =>
target.loadName === loadName &&
target.namespace === namespace &&
target.version === version &&
(parent === null || target.parent === parent)

const calData = calibrations
.filter(({ attributes }) => matchesLabwareIdentity(attributes))
.filter(({ attributes }) =>
matchesLabwareIdentityForCalibration(attributes)
)
.map(({ attributes }) => {
const calVector = attributes.calibrationData.offset.value.map(n =>
round(n, 1)
Expand Down