Module: ThinkFeelDoEngine::Coach::MoodsAndPhqVizHelper

Defined in:
app/helpers/think_feel_do_engine/coach/moods_and_phq_viz_helper.rb

Overview

Provides helpers for transforming patient data for the viz

Instance Method Summary collapse

Instance Method Details

#emotional_ratings(participant) ⇒ Object



6
7
8
9
10
11
12
13
# File 'app/helpers/think_feel_do_engine/coach/moods_and_phq_viz_helper.rb', line 6

def emotional_ratings(participant)
  ratings = {}
  participant.emotional_ratings.order(:created_at).each do |rating|
    ratings[rating.name.to_sym] = ratings[rating.name.to_sym] || []
    ratings[rating.name.to_sym] << [rating.created_at.to_i, rating.rating]
  end
  ratings.keys.map { |key| [key.to_sym, ratings[key.to_sym]] }
end

#mood_ratings(participant) ⇒ Object



15
16
17
18
19
# File 'app/helpers/think_feel_do_engine/coach/moods_and_phq_viz_helper.rb', line 15

def mood_ratings(participant)
  participant.moods.order(:created_at).map do |mood|
    [mood.created_at.to_i, mood.rating]
  end
end