Skip to content

Instantly share code, notes, and snippets.

@tbbooher
Last active September 13, 2015 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbbooher/21243a6a455a7aed8d44 to your computer and use it in GitHub Desktop.
Save tbbooher/21243a6a455a7aed8d44 to your computer and use it in GitHub Desktop.
just getting things in the right format
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