think_feel_do_engine 3.21.0 → 3.21.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/think_feel_do_engine/quick_sign_ins_controller.rb +4 -3
- data/app/helpers/think_feel_do_engine/coach/moods_and_phq_viz_helper.rb +1 -3
- data/app/helpers/think_feel_do_engine/coach/patient_dashboard_helper.rb +4 -4
- data/app/models/emotion.rb +3 -3
- data/app/models/emotional_rating.rb +3 -3
- data/app/models/group_metrics/weekly_activities_count.rb +48 -8
- data/app/models/group_metrics/weekly_count.rb +2 -2
- data/app/models/media_access_event.rb +1 -1
- data/app/models/message_sms_notification.rb +1 -3
- data/app/models/participant.rb +19 -23
- data/app/models/phq_stepping.rb +2 -3
- data/app/models/think_feel_do_engine/reports/lesson_module.rb +1 -1
- data/app/models/think_feel_do_engine/reports/lesson_slide_view.rb +6 -6
- data/app/models/think_feel_do_engine/reports/lesson_viewing.rb +1 -1
- data/app/models/think_feel_do_engine/reports/module_page_view.rb +1 -1
- data/app/models/think_feel_do_engine/reports/module_session.rb +1 -1
- data/app/models/think_feel_do_engine/reports/tool_module.rb +1 -1
- data/app/models/think_feel_do_engine/reports/video_session.rb +1 -1
- data/app/views/think_feel_do_engine/coach/group_dashboard/_summary.html.erb +12 -4
- data/lib/think_feel_do_engine/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20f20efba264a83a66b5d1824cae5ec07e8ef288
|
4
|
+
data.tar.gz: c30f8503fa62eb29007585f29f0c8cc6dfe66c39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d77b928f8354233495ac71d69f461b41664089c3561c08e2dc70814d2e37c633f43123c09c5addbea86f8f544ef578528f209aaa3d92fdeea41ee7a4f96b656d
|
7
|
+
data.tar.gz: bb916dabaf273b4e6c552d58760d28476b69b2e51a9769fdf7dc9e92640e710bc2739fb5fdfb4411a39fb3dcf8f4ebd54dd7f93f0e12b7f83f8011c897166b43
|
@@ -13,9 +13,10 @@ module ThinkFeelDoEngine
|
|
13
13
|
ParticipantLoginEvent.create(participant_id: params[:participant_id])
|
14
14
|
resource = Participant.where(id: params[:participant_id]).first
|
15
15
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
|
17
|
+
return unless resource
|
18
|
+
|
19
|
+
sign_in_and_redirect resource
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
@@ -6,9 +6,7 @@ module ThinkFeelDoEngine
|
|
6
6
|
def emotional_ratings(participant)
|
7
7
|
ratings = {}
|
8
8
|
participant.emotional_ratings.order(:created_at).each do |rating|
|
9
|
-
|
10
|
-
ratings[rating.name.to_sym] = []
|
11
|
-
end
|
9
|
+
ratings[rating.name.to_sym] = ratings[rating.name.to_sym] || []
|
12
10
|
ratings[rating.name.to_sym] << [rating.created_at.to_i, rating.rating]
|
13
11
|
end
|
14
12
|
ratings.keys.map { |key| [key.to_sym, ratings[key.to_sym]] }
|
@@ -3,10 +3,10 @@ module ThinkFeelDoEngine
|
|
3
3
|
module Coach
|
4
4
|
# Displays navigational information in the form of breadcrumbs
|
5
5
|
module PatientDashboardHelper
|
6
|
-
VISUALIZATION_CONTROLLERS =
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
VISUALIZATION_CONTROLLERS = %w(
|
7
|
+
participant_activities_visualizations
|
8
|
+
participant_thoughts_visualizations
|
9
|
+
).freeze
|
10
10
|
|
11
11
|
def breadcrumbs
|
12
12
|
return unless VISUALIZATION_CONTROLLERS.include?(controller_name)
|
data/app/models/emotion.rb
CHANGED
@@ -25,8 +25,8 @@ class Emotion < ActiveRecord::Base
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def normalize_name
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
return unless name.respond_to?(:strip)
|
29
|
+
|
30
|
+
self.name = self.class.normalized_name(name)
|
31
31
|
end
|
32
32
|
end
|
@@ -39,8 +39,8 @@ class EmotionalRating < ActiveRecord::Base
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def associate_emotion
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
return unless @name.present?
|
43
|
+
|
44
|
+
self.emotion = Emotion.associate(participant, @name)
|
45
45
|
end
|
46
46
|
end
|
@@ -4,18 +4,58 @@ module GroupMetrics
|
|
4
4
|
class WeeklyActivitiesCount < WeeklyCount
|
5
5
|
self.table_name = "activities"
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
def self.fetch(group_id)
|
8
|
+
super(group_id, "start_time")
|
9
|
+
end
|
10
|
+
|
11
|
+
scope :monitored, lambda {
|
12
|
+
where(is_reviewed: false)
|
13
|
+
.where
|
14
|
+
.not(
|
15
|
+
actual_accomplishment_intensity: nil,
|
16
|
+
actual_pleasure_intensity: nil
|
17
|
+
)
|
18
|
+
.where(
|
19
|
+
predicted_accomplishment_intensity: nil,
|
20
|
+
predicted_pleasure_intensity: nil
|
21
|
+
)
|
9
22
|
}
|
10
23
|
|
11
|
-
|
12
|
-
# change to start_time and is_scheduled
|
13
|
-
# and updated tests
|
14
|
-
scope :unscheduled_or_in_the_future, lambda {
|
24
|
+
scope :planned, lambda {
|
15
25
|
where(
|
16
|
-
|
17
|
-
|
26
|
+
is_reviewed: false,
|
27
|
+
actual_accomplishment_intensity: nil,
|
28
|
+
actual_pleasure_intensity: nil
|
18
29
|
)
|
30
|
+
.where
|
31
|
+
.not(
|
32
|
+
predicted_accomplishment_intensity: nil,
|
33
|
+
predicted_pleasure_intensity: nil
|
34
|
+
)
|
35
|
+
}
|
36
|
+
|
37
|
+
scope :reviewed_and_complete, lambda {
|
38
|
+
where(is_reviewed: true)
|
39
|
+
.where
|
40
|
+
.not(
|
41
|
+
predicted_accomplishment_intensity: nil,
|
42
|
+
predicted_pleasure_intensity: nil,
|
43
|
+
actual_accomplishment_intensity: nil,
|
44
|
+
actual_pleasure_intensity: nil
|
45
|
+
)
|
46
|
+
}
|
47
|
+
|
48
|
+
scope :reviewed_and_incomplete, lambda {
|
49
|
+
where(is_reviewed: true)
|
50
|
+
.where(
|
51
|
+
actual_accomplishment_intensity: nil,
|
52
|
+
actual_pleasure_intensity: nil
|
53
|
+
)
|
54
|
+
.where
|
55
|
+
.not(
|
56
|
+
predicted_accomplishment_intensity: nil,
|
57
|
+
predicted_pleasure_intensity: nil
|
58
|
+
)
|
19
59
|
}
|
20
60
|
end
|
21
61
|
end
|
@@ -8,13 +8,13 @@ module GroupMetrics
|
|
8
8
|
foreign_key: :participant_id,
|
9
9
|
primary_key: :participant_id
|
10
10
|
|
11
|
-
def self.fetch(group_id)
|
11
|
+
def self.fetch(group_id, timestamp_column = "created_at")
|
12
12
|
pg_timezone = ActiveSupport::TimeZone[Time.zone.name].tzinfo.name
|
13
13
|
|
14
14
|
joins(memberships: :participant)
|
15
15
|
.select(<<-SQL
|
16
16
|
( FLOOR ( EXTRACT ( EPOCH FROM (
|
17
|
-
( #{connection.quote_table_name(table_name)}.
|
17
|
+
( #{connection.quote_table_name(table_name)}.#{connection.quote_table_name(timestamp_column)}
|
18
18
|
AT TIME ZONE 'UTC' ) AT TIME ZONE #{connection.quote(pg_timezone)}
|
19
19
|
- memberships.start_date ) ) / 604800 ) + 1
|
20
20
|
)::int AS week, COUNT(1)
|
@@ -6,7 +6,7 @@ class MediaAccessEvent < ActiveRecord::Base
|
|
6
6
|
belongs_to :slide,
|
7
7
|
class_name: "BitCore::Slide",
|
8
8
|
foreign_key: :bit_core_slide_id
|
9
|
-
validates :media_type, inclusion: { in:
|
9
|
+
validates :media_type, inclusion: { in: %w(audio video) }
|
10
10
|
validates :media_link,
|
11
11
|
:participant,
|
12
12
|
:slide,
|
data/app/models/participant.rb
CHANGED
@@ -119,19 +119,19 @@ class Participant < ActiveRecord::Base
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def populate_emotions
|
122
|
-
emotions_array =
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
122
|
+
emotions_array = %w(
|
123
|
+
Anxious
|
124
|
+
Enthusiastic
|
125
|
+
Grateful
|
126
|
+
Happy
|
127
|
+
Irritable
|
128
|
+
Upset
|
129
|
+
Sad
|
130
|
+
Guilty
|
131
|
+
Calm
|
132
|
+
Concentrated
|
133
|
+
Relaxed
|
134
|
+
)
|
135
135
|
emotions_array.each do |e|
|
136
136
|
emotions.find_or_create_by(name: e)
|
137
137
|
end
|
@@ -162,7 +162,7 @@ class Participant < ActiveRecord::Base
|
|
162
162
|
end
|
163
163
|
|
164
164
|
def current_group
|
165
|
-
active_membership.group
|
165
|
+
active_membership.try(:group)
|
166
166
|
end
|
167
167
|
|
168
168
|
def fetch_data_record(association, id)
|
@@ -257,21 +257,17 @@ class Participant < ActiveRecord::Base
|
|
257
257
|
end
|
258
258
|
|
259
259
|
def positive_emotions(emotion_array)
|
260
|
-
|
261
|
-
if emotion.is_positive
|
262
|
-
|
263
|
-
end
|
264
|
-
end
|
265
|
-
emotions.compact
|
260
|
+
emotion_array.collect do |emotion|
|
261
|
+
[emotion.rating, emotion.created_at, emotion.name] if emotion.is_positive
|
262
|
+
end.compact
|
266
263
|
end
|
267
264
|
|
268
265
|
def negative_emotions(emotion_array)
|
269
|
-
|
266
|
+
emotion_array.collect do |emotion|
|
270
267
|
unless emotion.is_positive
|
271
268
|
[emotion.rating, emotion.created_at, emotion.name]
|
272
269
|
end
|
273
|
-
end
|
274
|
-
emotions.compact
|
270
|
+
end.compact
|
275
271
|
end
|
276
272
|
|
277
273
|
def most_recent_membership
|
data/app/models/phq_stepping.rb
CHANGED
@@ -151,9 +151,8 @@ class PhqStepping
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def filter_assessments(start)
|
154
|
-
if start == @week
|
155
|
-
|
156
|
-
end
|
154
|
+
start -= 1 if start == @week
|
155
|
+
|
157
156
|
@assessments.select! do |assessment|
|
158
157
|
assessment.week_of_assessment.to_i >= start &&
|
159
158
|
assessment.week_of_assessment.to_i <= @week
|
@@ -3,7 +3,7 @@ module ThinkFeelDoEngine
|
|
3
3
|
module Reports
|
4
4
|
# Shared Lesson Module behavior.
|
5
5
|
module LessonModule
|
6
|
-
URL_ROOT_RE =
|
6
|
+
URL_ROOT_RE = %r{^[^\/]*\/\/[^\/]+}
|
7
7
|
# Disabling method length due to nested methods.
|
8
8
|
# rubocop:disable Metrics/MethodLength,Lint/NestedMethodDefinition
|
9
9
|
def self.included(klass)
|
@@ -69,7 +69,7 @@ module ThinkFeelDoEngine
|
|
69
69
|
.order(:emitted_at)
|
70
70
|
.to_a.map do |e|
|
71
71
|
key = lessons.keys.find do |l|
|
72
|
-
!e.current_url.match(
|
72
|
+
!e.current_url.match(%r{#{ l }(\/.*)?$}).nil?
|
73
73
|
end
|
74
74
|
|
75
75
|
key ? [lessons[key], e] : nil
|
@@ -88,11 +88,11 @@ module ThinkFeelDoEngine
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def self.find_slide_by_url(slides, url)
|
91
|
-
slide_position =
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
slide_position = if url.match(%r{modules\/\d+$}).nil?
|
92
|
+
url[/\d+$/].to_i
|
93
|
+
else
|
94
|
+
1
|
95
|
+
end
|
96
96
|
|
97
97
|
slides.find_by_position(slide_position) unless slides.empty?
|
98
98
|
end
|
@@ -38,7 +38,7 @@ module ThinkFeelDoEngine
|
|
38
38
|
.select(:participant_id, :emitted_at, :payload)
|
39
39
|
.to_a.map do |e|
|
40
40
|
key = modules.keys.find do |l|
|
41
|
-
!e.current_url.match(
|
41
|
+
!e.current_url.match(%r{#{ l }(\/.*)?$}).nil?
|
42
42
|
end
|
43
43
|
|
44
44
|
key ? [modules[key], e] : nil
|
@@ -88,7 +88,7 @@ module ThinkFeelDoEngine
|
|
88
88
|
.drop_while { |e| e.id != first_session_event.id }
|
89
89
|
.take_while do |e|
|
90
90
|
e.emitted_at - latest_event_time < THRESHOLD &&
|
91
|
-
e.current_url.match(
|
91
|
+
e.current_url.match(%r{modules\/#{ module_id }(\/.*)?$}) &&
|
92
92
|
(latest_event_time = e.emitted_at)
|
93
93
|
end
|
94
94
|
last_event = (module_events.last || first_session_event)
|
@@ -11,7 +11,7 @@ module ThinkFeelDoEngine
|
|
11
11
|
def self.all
|
12
12
|
Participant.not_moderator.select(:id, :study_id).map do |participant|
|
13
13
|
video_play_events(participant.id).map do |e|
|
14
|
-
m = e.current_url.match(
|
14
|
+
m = e.current_url.match(%r{.*\/providers\/(\d+)\/(\d+)$})
|
15
15
|
provider_id = m ? m[1] : -1
|
16
16
|
position = m ? m[2] : -1
|
17
17
|
video = BitCore::ContentProvider
|
@@ -13,10 +13,18 @@
|
|
13
13
|
<%= render "weekly_counts", klass: GroupMetrics::WeeklyThoughtsCount, group_id: group.id, weeks: study_length_in_weeks %>
|
14
14
|
</tr>
|
15
15
|
<tr>
|
16
|
-
<td><a href="#
|
17
|
-
<%= render "weekly_counts", klass: GroupMetrics::WeeklyActivitiesCount.
|
16
|
+
<td><a href="#activities_future_table">activities monitored</a></td>
|
17
|
+
<%= render "weekly_counts", klass: GroupMetrics::WeeklyActivitiesCount.monitored, group_id: group.id, weeks: study_length_in_weeks %>
|
18
18
|
</tr>
|
19
19
|
<tr>
|
20
|
-
<td><a href="#
|
21
|
-
<%= render "weekly_counts", klass: GroupMetrics::WeeklyActivitiesCount.
|
20
|
+
<td><a href="#activities_past_table">activities planned</a></td>
|
21
|
+
<%= render "weekly_counts", klass: GroupMetrics::WeeklyActivitiesCount.planned, group_id: group.id, weeks: study_length_in_weeks %>
|
22
|
+
</tr>
|
23
|
+
<tr>
|
24
|
+
<td><a href="#activities_future_table">activities reviewed and complete</a></td>
|
25
|
+
<%= render "weekly_counts", klass: GroupMetrics::WeeklyActivitiesCount.reviewed_and_complete, group_id: group.id, weeks: study_length_in_weeks %>
|
26
|
+
</tr>
|
27
|
+
<tr>
|
28
|
+
<td><a href="#activities_future_table">activities reviewed and incomplete</a></td>
|
29
|
+
<%= render "weekly_counts", klass: GroupMetrics::WeeklyActivitiesCount.reviewed_and_incomplete, group_id: group.id, weeks: study_length_in_weeks %>
|
22
30
|
</tr>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: think_feel_do_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.21.
|
4
|
+
version: 3.21.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Carty-Fickes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|