director/lib/director/jobs/update_release.rb
def pick_best(collection, original_version)
        collection.sort_by { |item|
          if item.version == original_version
            1
          elsif Bosh::Common::VersionNumber.new(item.version).final?
            2
          elsif item.is_a?(Bosh::Director::Models::Package)
            3000 - [item.compiled_packages.size, 900].min
          else
            3000
          end
        }.first
      end
# Picks the best matching package/job from collection based on a simple
# heuristics: items with same version are preferred, then items
# with non-dev versions, then items with most compiled packages,
# then everything else.
# @param [Array<#name,#version>] collection
# @param [String] original_version
Picks the best matching package/job from collection based on a simple
heuristics: items with same version are preferred, then items
with non-dev versions, then items with most compiled packages,
then everything else.
Picks the best matching package / job from collection based on a simple heuristics : items with same version are preferred then items with non - dev versions then items with most compiled packages then everything else .
def pick_best(collection, original_version)
        collection.sort_by { |item|
          if item.version == original_version
            1
          elsif Bosh::Common::VersionNumber.new(item.version).final?
            2
          elsif item.is_a?(Bosh::Director::Models::Package)
            3000 - [item.compiled_packages.size, 900].min
          else
            3000
          end
        }.first
      end
def pick_best ( collection , original_version ) collection . sort_by { | item | if item . version == original_version 1 elsif Bosh :: Common :: VersionNumber . new ( item . version ) . final? 2 elsif item . is_a? ( Bosh :: Director :: Models :: Package ) 3000 - [ item . compiled_packages . size , 900 ] . min else 3000 end } . first end
Picks the best matching package/job from collection based on a simple
heuristics: items with same version are preferred, then items
with non-dev versions, then items with most compiled packages,
then everything else.
Picks the best matching package / job from collection based on a simple heuristics : items with same version are preferred then items with non - dev versions then items with most compiled packages then everything else .
collection
original_version
None