Skip to main content

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 associated

Syntax

getClosestAncestor(assets, shiftBlocks, assetPath, rangeStart, rangeEnd, tzOffsets)
  • Parameters
      assets (list[dict])
      shiftBlocks (list[dict])
      assetPath (string)
      rangeStart (Datetime)
      rangeEnd (Datetime)
      tzOffsets (dict)
  • Returns
      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)