app/mutations/sequences/celery_script_validators.rb
def deps(sequence)
      return [] unless checker.valid? # Exit early if it's bad data
      all = [] # Start collecting the list.
      CeleryScript::TreeClimber.travel(tree, ->(n) {
        # Iterate over each node, looking for "args of interest".
        # Tools, sub sequences, etc.
        ARGS_OF_INTEREST.map do |arg, klass|
          id = n&.args&.fetch(arg, nil)&.value
          all.push(klass.find(id)) if id
        end
      })

      # Filter out the target sequence to prevent runaway recursion.
      # It would be impossible to delete recursive sequences otherwise.
      all.select! { |d| !(d.is_a?(Sequence) && (d.id == sequence.id)) }

      # Finally, output the data in a format that can directly be used by
      # SequenceDependency#create!().
      return all.uniq.map do |d|
        { sequence: sequence, dependency_type: d.class, dependency_id: d.id }
      end
    end
# Climbs through every node in a sequence and finds out which dependencies
# will need to be kept track of
Climbs through every node in a sequence and finds out which dependencies
will need to be kept track of
Climbs through every node in a sequence and finds out which dependencies will need to be kept track of
def deps(sequence)
      return [] unless checker.valid? 
      all = [] 
      CeleryScript::TreeClimber.travel(tree, ->(n) {
        ARGS_OF_INTEREST.map do |arg, klass|
          id = n&.args&.fetch(arg, nil)&.value
          all.push(klass.find(id)) if id
        end
      })
      all.select! { |d| !(d.is_a?(Sequence) && (d.id == sequence.id)) }
      return all.uniq.map do |d|
        { sequence: sequence, dependency_type: d.class, dependency_id: d.id }
      end
    end
def deps ( sequence ) return [ ] unless checker . valid? all = [ ] CeleryScript :: TreeClimber . travel ( tree , -> ( n ) { ARGS_OF_INTEREST . map do | arg , klass | id = n &. args &. fetch ( arg , nil ) &. value all . push ( klass . find ( id ) ) if id end } ) all . select! { | d | ! ( d . is_a? ( Sequence ) && ( d . id == sequence . id ) ) } return all . uniq . map do | d | { sequence : sequence , dependency_type : d . class , dependency_id : d . id } end end
Climbs through every node in a sequence and finds out which dependencies
will need to be kept track of
Climbs through every node in a sequence and finds out which dependencies will need to be kept track of
# Exit early if it's bad data # Start collecting the list. # Iterate over each node, looking for "args of interest". # Tools, sub sequences, etc. # Filter out the target sequence to prevent runaway recursion. # It would be impossible to delete recursive sequences otherwise. # Finally, output the data in a format that can directly be used by # SequenceDependency#create!().
sequence