system.kanoa.shift.getClosestAncestor
Description
Recursive function that returns the assetPath with shifts associated to it, in order of the asset path tree. Returns None if no shifts are associatedSyntax
getClosestAncestor(assets, shiftBlocks, assetPath, rangeStart, rangeEnd, tzOffsets)- assets (list[dict])
- shiftBlocks (list[dict])
- assetPath (string)
- rangeStart (Datetime)
- rangeEnd (Datetime)
- tzOffsets (dict)
- assetPath (string)
Code Example
assetPath = 'Kanoa Inductries\Adelaide Hills\Packaging\Line 1'
startDate = system.date.parse("2025-01-01 00:00:00")
endDate = system.date.parse("2025-01-07 00:00:00")
assets = system.kanoa.utilities.convertDatasetToDict(system.kanoa.asset.getAssets({}), 'assetPath', None)
tzOffsets = {'Pacific Standard Time': {startOffsetMins': -480, 'endOffSetMins': -480}}
shiftBlocks = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.shift.getShiftBlocks({'recurring': True}))
ancestorPath = system.kanoa.shift.getClosestAncestor(assets, shiftBlocks, assetPath, startDate, endDate, tzOffsets)