think_feel_do_engine 3.21.0 → 3.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3bcad632eb10037be393711c01e5b9c62f00081
4
- data.tar.gz: dd748908ba0ebf80bc86c672b08674b2cf102445
3
+ metadata.gz: 20f20efba264a83a66b5d1824cae5ec07e8ef288
4
+ data.tar.gz: c30f8503fa62eb29007585f29f0c8cc6dfe66c39
5
5
  SHA512:
6
- metadata.gz: 5a85a6b07d8f54f14325bdfe0e27a39f56bb7fd27f38246136eef69237cb7b94c706f14215332ac280a55290d6bffb43684f46800be6cfb6ba8b25102c7e44bc
7
- data.tar.gz: 3d34f12e972f003b2a80dc845235fd1356cd92d235a925fa3bce3783081122e4cc1267b68bea2905d8a8c2f7560958b92941925d59227361a6cead68e16a648b
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
- if resource
17
- sign_in_and_redirect resource
18
- end
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
- unless ratings[rating.name.to_sym]
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
- "participant_activities_visualizations",
8
- "participant_thoughts_visualizations"
9
- ].freeze
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)
@@ -25,8 +25,8 @@ class Emotion < ActiveRecord::Base
25
25
  private
26
26
 
27
27
  def normalize_name
28
- if name.respond_to?(:strip)
29
- self.name = self.class.normalized_name(name)
30
- end
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
- if @name.present?
43
- self.emotion = Emotion.associate(participant, @name)
44
- end
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
- scope :in_the_past, lambda {
8
- where arel_table[:end_time].lt(Time.zone.now)
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
- # To Do: fix naming and/or what is going on here
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
- arel_table[:start_time].eq(nil)
17
- .or(arel_table[:end_time].gt(Time.zone.now))
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)}.created_at
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: ["audio", "video"] }
9
+ validates :media_type, inclusion: { in: %w(audio video) }
10
10
  validates :media_link,
11
11
  :participant,
12
12
  :slide,
@@ -41,9 +41,7 @@ class MessageSmsNotification
41
41
  body: body
42
42
  }
43
43
 
44
- if status_callback_url
45
- params[:status_callback] = status_callback_url
46
- end
44
+ params[:status_callback] = status_callback_url if status_callback_url
47
45
 
48
46
  params
49
47
  end
@@ -119,19 +119,19 @@ class Participant < ActiveRecord::Base
119
119
  end
120
120
 
121
121
  def populate_emotions
122
- emotions_array = [
123
- "Anxious",
124
- "Enthusiastic",
125
- "Grateful",
126
- "Happy",
127
- "Irritable",
128
- "Upset",
129
- "Sad",
130
- "Guilty",
131
- "Calm",
132
- "Concentrated",
133
- "Relaxed"
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
- emotions = emotion_array.collect do |emotion|
261
- if emotion.is_positive
262
- [emotion.rating, emotion.created_at, emotion.name]
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
- emotions = emotion_array.collect do |emotion|
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
@@ -151,9 +151,8 @@ class PhqStepping
151
151
  end
152
152
 
153
153
  def filter_assessments(start)
154
- if start == @week
155
- start -= 1
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(/#{ l }(\/.*)?$/).nil?
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 = 1
92
-
93
- if url.match(/modules\/\d+$/).nil?
94
- slide_position = url[/\d+$/].to_i
95
- end
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
@@ -5,7 +5,7 @@ module ThinkFeelDoEngine
5
5
  class LessonViewing
6
6
  include LessonModule
7
7
 
8
- DEFAULT_LESSON_MODULE_POSTFIX = /\/providers\/.*/
8
+ DEFAULT_LESSON_MODULE_POSTFIX = %r{\/providers\/.*}
9
9
 
10
10
  def self.columns
11
11
  %w( participant_id lesson_id page_headers lesson_selected_at
@@ -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(/#{ l }(\/.*)?$/).nil?
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(/modules\/#{ module_id }(\/.*)?$/) &&
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)
@@ -4,7 +4,7 @@ module ThinkFeelDoEngine
4
4
  # Helper methods for reporting on modules.
5
5
  # rubocop:disable Lint/NestedMethodDefinition
6
6
  module ToolModule
7
- URL_ROOT_RE = /^[^\/]*\/\/[^\/]+/
7
+ URL_ROOT_RE = %r{^[^\/]*\/\/[^\/]+}
8
8
 
9
9
  def self.included(klass)
10
10
  class << klass
@@ -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(/.*\/providers\/(\d+)\/(\d+)$/)
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="#activities_past_table">activities past</a></td>
17
- <%= render "weekly_counts", klass: GroupMetrics::WeeklyActivitiesCount.in_the_past, group_id: group.id, weeks: study_length_in_weeks %>
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="#activities_future_table">activities future</a></td>
21
- <%= render "weekly_counts", klass: GroupMetrics::WeeklyActivitiesCount.unscheduled_or_in_the_future, group_id: group.id, weeks: study_length_in_weeks %>
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>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # nodoc
3
3
  module ThinkFeelDoEngine
4
- VERSION = "3.21.0"
4
+ VERSION = "3.21.1"
5
5
  end
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.0
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-20 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails