Created
May 31, 2012 22:31
-
-
Save enthal/2846798 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 mr | |
# total_sponsor_amount = sum{|d| d.amount * dollars_per_locale_currency_unit(d.locale)} | |
reduce = { | |
usd_per_could_sponsor: ->(d){d.usd / d.could_count}, | |
usd_per_did_sponsor: ->(d){d.usd / d.did_count}, | |
} | |
map = { | |
usd: where(->(d){d.type == :did_member_sponsor}, sum{|d| d.amount * dollars_per_locale_currency_unit(d.locale)}), | |
could_count: count{|d| d.type == :could_member_sponsor}, | |
did_count: count{|d| d.type == :did_member_sponsor} | |
} | |
# :usd_per_did_sponsor, {sum{|d| d.amount * dollars_per_locale_currency_unit(d.locale)} / count{|d| d.type == :did_member_sponsor}} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment