Skip to content

Instantly share code, notes, and snippets.

@chewmanfoo
Created March 21, 2012 18:29
Show Gist options
  • Save chewmanfoo/2150809 to your computer and use it in GitHub Desktop.
Save chewmanfoo/2150809 to your computer and use it in GitHub Desktop.
def self.release_steps(current, new, carrier)
@upgrade = Array.new
@all = SoftwareRelease.find_all_by_feature_group_id(current.feature_group_id)
@all.group_by(&:major).each do |m,ss|
ss.sort_by(&:minor).group_by(&:minor).each do |n,sc|
rel=sc.sort_by(&:micro).last
if rel.applicable_carriers
@upgrade.push(rel.id) if rel.applicable_carriers.split(",").map{|i| i.to_i}.include?(carrier.id)
end
end
end
# upgrade is a sorted array, now trim releases before current
@upgrade.each do |i|
i_rel = SoftwareRelease.find(i)
if (i_rel.major = current.major && i_rel.minor == current.minor)
@upgrade.pop(irel_id) #<--- help here?
end
end
@upgrade
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment