Skip to content

Instantly share code, notes, and snippets.

@benhoskings
Created September 3, 2014 07:46
Show Gist options
  • Save benhoskings/688186f4791f1bd719bb to your computer and use it in GitHub Desktop.
Save benhoskings/688186f4791f1bd719bb to your computer and use it in GitHub Desktop.
def self.cumulative_by_month model, column
tally = 0
count_by_month(model, column).map do |(month, count)|
[month, tally += count]
end
end
def self.cumulative_by_month_inject model, column
count_by_month(model, column).tap {|pairs|
pairs.inject(0) do |tally,pair|
pair[1] = tally + pair[1]
end
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment