Last active
September 13, 2015 03:17
-
-
Save tbbooher/21243a6a455a7aed8d44 to your computer and use it in GitHub Desktop.
just getting things in the right format
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 integer_quantities | |
quantities = [:purity, :devotional, :discipline, :fitness, :wife, :relational, :stress, :facepicking] | |
data = Hash.new | |
# initialize the hashes | |
quantities.each do |q| | |
data[q] = [] | |
end | |
# only want one db query -- so need to populate the data for each | |
self.journal_entries.each do |j| | |
quantities.each do |q| | |
data[q].push([j.entry_date, j[q]]) | |
end | |
end | |
# now, build the hash | |
quantities.map do |q| | |
{"name" => q.to_s, "data" => data[q]} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment