third_party/pipeline/pipeline/ui/status.js
function findActivePipeline(pipelineId, isRoot) {
  var infoMap = STATUS_MAP.pipelines[pipelineId];
  if (!infoMap) {
    return null;
  }

  // This is an active leaf node.
  if (infoMap.children.length == 0 && infoMap.status != 'done') {
    return pipelineId;
  }

  // Sort children by start time only.
  var children = infoMap.children.slice(0);
  children.sort(function(a, b) {
    var infoMapA = STATUS_MAP.pipelines[a];
    var infoMapB = STATUS_MAP.pipelines[b];
    if (!infoMapA || !infoMapB) {
      return 0;
    }
    if (infoMapA.startTimeMs && infoMapB.startTimeMs) {
      return infoMapA.startTimeMs - infoMapB.startTimeMs;
    } else {
      return 0;
    }
  });

  for (var i = 0; i < children.length; ++i) {
    var foundPipelineId = findActivePipeline(children[i], false);
    if (foundPipelineId != null) {
      return foundPipelineId;
    }
  }

  return null;
}
function findActivePipeline(pipelineId, isRoot) {
  var infoMap = STATUS_MAP.pipelines[pipelineId];
  if (!infoMap) {
    return null;
  }

  // This is an active leaf node.
  if (infoMap.children.length == 0 && infoMap.status != 'done') {
    return pipelineId;
  }

  // Sort children by start time only.
  var children = infoMap.children.slice(0);
  children.sort(function(a, b) {
    var infoMapA = STATUS_MAP.pipelines[a];
    var infoMapB = STATUS_MAP.pipelines[b];
    if (!infoMapA || !infoMapB) {
      return 0;
    }
    if (infoMapA.startTimeMs && infoMapB.startTimeMs) {
      return infoMapA.startTimeMs - infoMapB.startTimeMs;
    } else {
      return 0;
    }
  });

  for (var i = 0; i < children.length; ++i) {
    var foundPipelineId = findActivePipeline(children[i], false);
    if (foundPipelineId != null) {
      return foundPipelineId;
    }
  }

  return null;
}
function findActivePipeline ( pipelineId , isRoot ) { var infoMap = STATUS_MAP . pipelines [ pipelineId ] ; if ( ! infoMap ) { return null ; } // This is an active leaf node. if ( infoMap . children . length == 0 && infoMap . status != 'done' ) { return pipelineId ; } // Sort children by start time only. var children = infoMap . children . slice ( 0 ) ; children . sort ( function ( a , b ) { var infoMapA = STATUS_MAP . pipelines [ a ] ; var infoMapB = STATUS_MAP . pipelines [ b ] ; if ( ! infoMapA || ! infoMapB ) { return 0 ; } if ( infoMapA . startTimeMs && infoMapB . startTimeMs ) { return infoMapA . startTimeMs - infoMapB . startTimeMs ; } else { return 0 ; } } ) ; for ( var i = 0 ; i < children . length ; ++ i ) { var foundPipelineId = findActivePipeline ( children [ i ] , false ) ; if ( foundPipelineId != null ) { return foundPipelineId ; } } return null ; }
Depth-first search for active pipeline.
Depth - first search for active pipeline .