-
-
Save siassaj/cd6a89e092f57fef9c6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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