-
-
Save apetrov/b3d61bb67fff6d2986d3 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
SiteEffectiveRates = Struct.new(:parent_id, :domain, :pricing, :data) | |
def map_sites(sites, result_set) | |
sites.map do |t| | |
result_set[t.id].map do |pricing, data| | |
SiteEffectiveRates.new(t.parent_id, t.host_from_url, pricing.to_sym, data ) | |
end | |
end.flatten | |
end | |
def map_learning(learning) | |
learning.map{ |t| SiteEffectiveRates.new(t.parent_id, t.domain, t.pricing.to_sym, LEARNING_RATES[t.pricing.to_sym]) } | |
end | |
def reduce(sites) | |
{}.tap do |result| | |
sites.each do |t| | |
result[t.parent_id] ||= {} | |
result[t.parent_id][t.domain]||={} | |
result[t.parent_id][t.domain][t.pricing] = t.data | |
end | |
end | |
end |
Author
apetrov
commented
Oct 7, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment