Skip to content

Instantly share code, notes, and snippets.

@siassaj
Created September 13, 2012 11:27
Show Gist options
  • Save siassaj/cd6a89e092f57fef9c6d to your computer and use it in GitHub Desktop.
Save siassaj/cd6a89e092f57fef9c6d to your computer and use it in GitHub Desktop.
def self.hash_by_comweek_fyear(comweek=0, fyear=0)
orders = self.by_comweek_fyear(comweek, fyear)
unless orders.empty?
o_miny = orders.first.fyoc
o_maxy = o_miny
orders.each do |order|
order.fyoc > o_maxy ? o_maxy = order.fyoc : nil
order.fyoc < o_miny ? o_miny = order.fyoc : nil
end
o_maxy.downto(o_miny).each do |y|
ords = orders.select { |o| o.fyoc == y }
unless ords.empty?
o_minw = ords.first.comweek
o_maxw = o_minw
ords.each do |o|
o.comweek > o_maxw ? o_maxy = o.comweek : nil
o.comweek < o_minw ? o_miny = o.comweek : nil
end
o_maxw.downto(o_minw).each do |w|
os = ords.select { |o| o.comweek == w }
end
end
end
end
end
@siassaj
Copy link
Author

siassaj commented Sep 13, 2012

def self.hash_by_comweek_fyear(comweek=0, fyear=0)
orders = self.by_comweek_fyear(comweek, fyear)
if orders.empty? then return nil end
o_miny,o_maxy = orders.minmax_by(&:fyoc)
o_maxy.downto(o_miny).each do |y|
ords = orders.select { |o| o.fyoc == y }
unless ords.empty?
o_minw,o_maxw = orders.minmax_by(&:comweek)
o_maxw.downto(o_minw).each do |w|
os = ords.select { |o| o.comweek == w }
end
end
end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment