Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Created April 11, 2014 13:34
Show Gist options
  • Save mikecmpbll/10469408 to your computer and use it in GitHub Desktop.
Save mikecmpbll/10469408 to your computer and use it in GitHub Desktop.
def self.me2
total_count = 0
total_new = Project.order(datum: :asc).group("date_format(datum, '%Y%m')").count.select{|d,c| d}
total_by_month = Hash[total_new.map { |month, n| [ month, total_count += n ]}]
end
def self.mike
new_users_by_month = Project.group("date_format(datum, '%Y%m')").count.select{|d,c| d}
total_users_by_month = Hash[new_users_by_month.map do |d, c|
[d, new_users_by_month.sum do |d2,c|
d2 <= d ? c : 0
end]
end]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment