Skip to main content

system.kanoa.shift.getClosestAncestor(assets, shiftBlocks, assetPath, rangeStart, rangeEnd, tzOffsets)

Returns the assetPath that has shifts associated to it in order of the asset path tree. if no shifts are associated, returns None


Parameters

assets List of Dictionaries: List of assets to search
shiftBlocks List of Dictionaries: list of shift blocks to search through
assetPath String: AssetPath we are looking for a shift
rangeStart DateTime: Start date of range
rangeEnd DateTime: End date of range
tzOffsets Dictionary: {'Pacific Standard Time': {startOffsetMins': -480, 'endOffSetMins': -480}}


Returns

assetPath String


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)