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(assetPath, rangeStart, rangeEnd, siteOffsetMins, deviceUTCOffsetHrs, counter)
  • Parameters
      assets (list[dict])
      shiftBlocks (list[dict])
      assetPath (string)
      rangeStart (Datetime)
      rangeEnd (Datetime)
  • Returns
      assetPath (string)
  • Code Example

    # Example Usage:
    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)
    shiftBlocks = system.kanoa.utilities.convertDatasetToJSON(system.kanoa.shift.getShiftBlocks({'recurring': True}))
    ancestorPath = system.kanoa.shift.getClosestAncestor(assets, shiftBlocks, assetPath, startDate, endDate)