think_feel_do_engine 3.19.6 → 3.19.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb +9 -9
  3. data/app/controllers/think_feel_do_engine/manage/tasks_controller.rb +3 -3
  4. data/app/helpers/think_feel_do_engine/coach/patient_dashboard_helper.rb +3 -3
  5. data/app/helpers/think_feel_do_engine/tasks_helper.rb +1 -1
  6. data/app/mailers/think_feel_do_engine/message_notifications.rb +2 -2
  7. data/app/models/arm.rb +2 -2
  8. data/app/models/concerns/accessibility.rb +1 -1
  9. data/app/models/concerns/copier.rb +2 -1
  10. data/app/models/content_providers/awake_period_form.rb +8 -4
  11. data/app/models/content_providers/module_index_provider.rb +2 -2
  12. data/app/models/content_providers/show_message_provider.rb +2 -2
  13. data/app/models/content_providers/your_activities_provider.rb +5 -3
  14. data/app/models/group_metrics/weekly_count.rb +1 -1
  15. data/app/models/media_access_event.rb +2 -2
  16. data/app/models/membership.rb +13 -13
  17. data/app/models/message.rb +1 -1
  18. data/app/models/participant.rb +3 -3
  19. data/app/models/participant_metrics/weekly_count.rb +1 -1
  20. data/app/models/phq_stepping.rb +1 -1
  21. data/app/models/phq_stepping_assessment.rb +2 -2
  22. data/app/models/task_status.rb +1 -1
  23. data/app/models/think_feel_do_engine/reports/reporter.rb +2 -0
  24. data/app/models/think_feel_do_engine/reports/video_session.rb +1 -2
  25. data/app/models/tool_nav_item.rb +3 -3
  26. data/app/presenters/think_feel_do_engine/media_access_event_presenter.rb +2 -1
  27. data/app/views/think_feel_do_engine/activities/past_activity_form.html.erb +1 -1
  28. data/lib/think_feel_do_engine/version.rb +1 -1
  29. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38fefce634cffdb4a6b618fbb51b9ae58c268eba
4
- data.tar.gz: a7c064412e870d344ac4c2569bcd64c8cc8e7fb4
3
+ metadata.gz: ae2ac67360cf4936becc3201ca3116aa5a2746a6
4
+ data.tar.gz: 6014a2de830f98bd3a06736f46b528184bd8e185
5
5
  SHA512:
6
- metadata.gz: f8c586eca19942ad7f3b8db29d306152afa3081c7b263cd011bf79bb8e2a0cc48691118295a0e0d9b85b6aed7e6836b97bf71e324f6a312ba66f7755640d9d99
7
- data.tar.gz: d54b4c58324ce7950cfdc0797beaefd7b73a58d576e6e49d6fb1d4e79e276d7aa9432742be028d6e848f8a600c51becdca7e858fea5666174436b3d35eff8367
6
+ metadata.gz: ab49783f7ad4d0feaa1693cd618dcd4157eca182b13f51e2569a37f881f3e3f28fe8ea6917b61d1d5abab8928de922f2c35cbe9554625dd3aa1bec29adc45da1
7
+ data.tar.gz: 64611db3bd1672d9607c30d6fd26ecbe41647af500c1837ea23fa8ccae031b43e2aff6bc7523200b89cd0ef6ca299c1c1f60fd86961e80fd85b3cd44cb7c6610
@@ -9,7 +9,7 @@ module ThinkFeelDoEngine
9
9
  before_action :authenticate_user!, :set_arm,
10
10
  :set_content_modules, :set_slideshows
11
11
 
12
- PROVIDER_NOT_FOUND = "The slide you are looking for no longer exists."
12
+ PROVIDER_NOT_FOUND = "Unable to find Content Provider"
13
13
 
14
14
  def index
15
15
  authorize! :index, BitCore::ContentProvider
@@ -18,14 +18,11 @@ module ThinkFeelDoEngine
18
18
 
19
19
  def show
20
20
  authorize! :show, BitCore::ContentProvider
21
- begin
22
- @content_provider = find_content_provider
23
-
24
- if @content_provider.source_content_id
25
- @slideshow = @content_provider.source_content
26
- end
27
- rescue ActiveRecord::RecordNotFound
28
- redirect_to main_app.root_path, alert: PROVIDER_NOT_FOUND
21
+
22
+ @content_provider = find_content_provider
23
+ if @content_provider.is_a?(BitCore::ContentProvider) &&
24
+ @content_provider.source_content_id
25
+ @slideshow = @content_provider.source_content
29
26
  end
30
27
  end
31
28
 
@@ -92,6 +89,9 @@ module ThinkFeelDoEngine
92
89
 
93
90
  def find_content_provider
94
91
  ContentProviderDecorator.fetch(params[:id])
92
+ rescue ActiveRecord::RecordNotFound
93
+ redirect_to arm_bit_maker_content_providers_url(@arm),
94
+ alert: PROVIDER_NOT_FOUND
95
95
  end
96
96
 
97
97
  def content_provider_params
@@ -30,13 +30,13 @@ module ThinkFeelDoEngine
30
30
  authorize! :destroy, @task
31
31
  group = @task.group
32
32
  if @task.complete_participant_list.present?
33
- flash.now[:alert] = "Unable to delete task from group: "\
33
+ flash[:alert] = "Unable to delete task from group, "\
34
34
  "at least one related task status is complete."
35
35
  elsif @task.destroy
36
- flash.now[:success] = "Task unassigned from group."
36
+ flash[:success] = "Task unassigned from group."
37
37
  else
38
38
  errors = @task.errors.full_messages.join(", ")
39
- flash[:error] = "Unable to delete task from group: #{ errors }"
39
+ flash[:alert] = "Unable to delete task from group: #{ errors }"
40
40
  end
41
41
  redirect_to arm_manage_tasks_group_path(group.arm, group)
42
42
  end
@@ -30,13 +30,13 @@ module ThinkFeelDoEngine
30
30
 
31
31
  def activities_planned_today(participant)
32
32
  participant
33
- .activities.planned.created_for_day(Date.today).count +
33
+ .activities.planned.created_for_day(Time.zone.today).count +
34
34
  participant
35
35
  .activities
36
- .reviewed_and_complete.created_for_day(Date.today).count +
36
+ .reviewed_and_complete.created_for_day(Time.zone.today).count +
37
37
  participant
38
38
  .activities
39
- .reviewed_and_incomplete.created_for_day(Date.today).count
39
+ .reviewed_and_incomplete.created_for_day(Time.zone.today).count
40
40
  end
41
41
 
42
42
  def activities_planned_7_day(participant)
@@ -90,7 +90,7 @@ module ThinkFeelDoEngine
90
90
  end
91
91
 
92
92
  def name
93
- icon.html_safe + " " + available_module.title
93
+ icon.html_safe + " " + available_module.title
94
94
  end
95
95
 
96
96
  private
@@ -5,7 +5,7 @@ module ThinkFeelDoEngine
5
5
  application_name = I18n.t(:application_name, default: "ThinkFeelDo")
6
6
  @group = group
7
7
  mail to: coach.email,
8
- subject: "#{application_name}: New message"
8
+ subject: "#{application_name}: You have a new message"
9
9
  end
10
10
 
11
11
  def new_for_participant(participant)
@@ -17,7 +17,7 @@ module ThinkFeelDoEngine
17
17
  .find_by_type("Tools::Messages")
18
18
  .title
19
19
  mail to: participant.email,
20
- subject: "#{application_name}: New message"
20
+ subject: "#{application_name}: You have a new message"
21
21
  end
22
22
  end
23
23
  end
data/app/models/arm.rb CHANGED
@@ -22,7 +22,7 @@ class Arm < ActiveRecord::Base
22
22
  intervention utilizes social features or the \
23
23
  participant is currently enrolled in an arm that \
24
24
  requires a display name."
25
- )
25
+ )
26
26
  false
27
27
  else
28
28
  true
@@ -42,6 +42,6 @@ class Arm < ActiveRecord::Base
42
42
  bit_core_tools
43
43
  .where(tools[:type].eq(nil)
44
44
  .or(tools[:type].not_eq("Tools::Home"))
45
- )
45
+ )
46
46
  end
47
47
  end
@@ -2,7 +2,7 @@ module Concerns
2
2
  # Determines whether a participant can access a lesson
3
3
  module Accessibility
4
4
  def accessible?
5
- available_for_learning_on <= Date.today
5
+ available_for_learning_on <= Time.zone.today
6
6
  end
7
7
 
8
8
  def available_for_learning_on
@@ -55,7 +55,8 @@ module Concerns
55
55
 
56
56
  def copy_content_modules_to(new_tool:)
57
57
  ContentModule.transaction do
58
- content_modules.where(type: LESSON_MODULE).each do |content_module|
58
+ content_modules.where(type: LESSON_MODULE)
59
+ .find_each do |content_module|
59
60
  content_module.copy_content_providers_to(
60
61
  new_tool: new_tool)
61
62
  end
@@ -43,13 +43,15 @@ module ContentProviders
43
43
  def wake_up_range(last_awake_time)
44
44
  start_time = [
45
45
  # 1 hour after last going to sleep
46
- last_awake_time ? (last_awake_time.end_time + 1.hour) : Time.at(0),
46
+ last_awake_time ? (last_awake_time.end_time + 1.hour) : Time.zone.at(0),
47
47
  # 12am yesterday
48
48
  (Time.current - 1.day).at_beginning_of_day
49
49
  ].max
50
50
  end_time = Time.current - 2.hours
51
51
 
52
- (start_time.to_i..end_time.to_i).step(1.hour).to_a.map { |t| Time.at(t) }
52
+ (start_time.to_i..end_time.to_i).step(1.hour).to_a.map do |t|
53
+ Time.zone.at(t)
54
+ end
53
55
  end
54
56
 
55
57
  def go_to_sleep_range(last_awake_time)
@@ -57,11 +59,13 @@ module ContentProviders
57
59
  # 1am yesterday
58
60
  (Time.current - 1.day).at_beginning_of_day + 1.hour,
59
61
  # 2 hours after last going to sleep
60
- last_awake_time ? (last_awake_time.end_time + 2.hours) : Time.at(0)
62
+ last_awake_time ? (last_awake_time.end_time + 2.hours) : Time.zone.at(0)
61
63
  ].max
62
64
  end_time = Time.current - 1.hour
63
65
 
64
- (start_time.to_i..end_time.to_i).step(1.hour).to_a.map { |t| Time.at(t) }
66
+ (start_time.to_i..end_time.to_i).step(1.hour).to_a.map do |t|
67
+ Time.zone.at(t)
68
+ end
65
69
  end
66
70
  end
67
71
  end
@@ -32,9 +32,9 @@ module ContentProviders
32
32
  AvailableContentModule
33
33
  .for_participant(options.participant)
34
34
  .for_tool(tool)
35
- .available_by(Date.current)
35
+ .available_by(Time.zone.today)
36
36
  .excludes_module(bit_core_content_module_id)
37
- .is_not_terminated_on(Date.current)
37
+ .is_not_terminated_on(Time.zone.today)
38
38
  .latest_duplicate
39
39
  end
40
40
  end
@@ -51,10 +51,10 @@ module ContentProviders
51
51
 
52
52
  received_message =
53
53
  participant.received_messages
54
- .where(message_id: view_context.params[:message_id]).first
54
+ .find_by(message_id: view_context.params[:message_id])
55
55
  sent_message =
56
56
  participant.messages
57
- .where(id: view_context.params[:message_id]).first
57
+ .find_by(id: view_context.params[:message_id])
58
58
 
59
59
  received_message || sent_message
60
60
  end
@@ -78,14 +78,16 @@ module ContentProviders
78
78
 
79
79
  # dates with scheduled activities formatted for jquery datepicker
80
80
  def collect_dates_with_activities(options)
81
- past_activities(options).where("start_time <= ?", Time.now)
81
+ past_activities(options).where("start_time <= ?", Time.zone.now)
82
82
  .uniq
83
83
  .map { |activity| activity.start_time.to_date.strftime("%Y-%m-%d") }
84
84
  end
85
85
 
86
86
  def local_time(options)
87
- if options.view_context.params[:date]
88
- options.view_context.params[:date].to_time
87
+ date = options.view_context.params[:date]
88
+
89
+ if date
90
+ Time.zone.parse(date)
89
91
  else
90
92
  Time.zone.now
91
93
  end
@@ -18,7 +18,7 @@ module GroupMetrics
18
18
  - memberships.start_date ) ) / 604800 ) + 1
19
19
  )::int AS week, COUNT(1)
20
20
  SQL
21
- )
21
+ )
22
22
  .merge(Participant.not_moderator)
23
23
  .merge(Membership.where(group_id: group_id))
24
24
  .group(:week)
@@ -16,9 +16,9 @@ class MediaAccessEvent < ActiveRecord::Base
16
16
  def task_release_day(group)
17
17
  module_id = slide.slideshow.content_provider.bit_core_content_module_id
18
18
 
19
- Task.where(
19
+ Task.find_by(
20
20
  bit_core_content_module_id: module_id,
21
21
  group_id: group.id
22
- ).first.release_day
22
+ ).release_day
23
23
  end
24
24
  end
@@ -33,16 +33,16 @@ class Membership < ActiveRecord::Base
33
33
 
34
34
  scope :active, lambda {
35
35
  where(
36
- arel_table[:start_date].lteq(Date.current)
37
- .and(arel_table[:end_date].gteq(Date.current))
36
+ arel_table[:start_date].lteq(Time.zone.today)
37
+ .and(arel_table[:end_date].gteq(Time.zone.today))
38
38
  .or(arel_table[:is_complete].eq(true))
39
39
  )
40
40
  }
41
41
 
42
42
  scope :inactive, lambda {
43
43
  where(
44
- arel_table[:start_date].gt(Date.current)
45
- .or(arel_table[:end_date].lt(Date.current))
44
+ arel_table[:start_date].gt(Time.zone.today)
45
+ .or(arel_table[:end_date].lt(Time.zone.today))
46
46
  )
47
47
  }
48
48
 
@@ -80,7 +80,7 @@ class Membership < ActiveRecord::Base
80
80
  end
81
81
 
82
82
  def day_in_study(date = nil)
83
- ((date || Date.current) - start_date).to_i + 1
83
+ ((date || Time.zone.today) - start_date).to_i + 1
84
84
  end
85
85
 
86
86
  def length_of_study
@@ -101,7 +101,7 @@ class Membership < ActiveRecord::Base
101
101
 
102
102
  def flag_complete
103
103
  self.is_complete = true
104
- self.end_date = Date.yesterday
104
+ self.end_date = 1.day.ago
105
105
 
106
106
  save validate: false
107
107
  end
@@ -122,9 +122,9 @@ class Membership < ActiveRecord::Base
122
122
  participant
123
123
  .participant_login_events
124
124
  .where(participant_login_events[:created_at]
125
- .gteq(Date.current.beginning_of_day))
125
+ .gteq(Time.zone.today.beginning_of_day))
126
126
  .where(participant_login_events[:created_at]
127
- .lt(Date.current.end_of_day))
127
+ .lt(Time.zone.today.end_of_day))
128
128
  end
129
129
 
130
130
  def lessons_read
@@ -151,13 +151,13 @@ class Membership < ActiveRecord::Base
151
151
  def withdraw
152
152
  return false unless valid?
153
153
 
154
- update_column(:end_date, Date.current - 1.day)
154
+ update_column(:end_date, Time.zone.today - 1.day)
155
155
  end
156
156
 
157
157
  def discontinue
158
158
  return false unless valid?
159
159
 
160
- update_columns(end_date: Date.current - 1.day, is_complete: true)
160
+ update_columns(end_date: Time.zone.today - 1.day, is_complete: true)
161
161
  end
162
162
 
163
163
  def week_start_day(week_number)
@@ -192,18 +192,18 @@ class Membership < ActiveRecord::Base
192
192
  end
193
193
 
194
194
  def not_complete_in_the_future
195
- return unless end_date && end_date > Date.today && is_complete == true
195
+ return unless end_date && end_date > Time.zone.today && is_complete == true
196
196
 
197
197
  errors.add :is_complete, "cannot be set to true for end dates in the future"
198
198
  end
199
199
 
200
200
  def not_ending_in_the_past
201
- return unless end_date && end_date_changed? && end_date < Date.current
201
+ return unless end_date && end_date_changed? && end_date < Time.zone.today
202
202
 
203
203
  errors.add :end_date, "must not be in the past"
204
204
  end
205
205
 
206
206
  def start_date_with_zone
207
- start_date.to_time
207
+ Time.zone.local(start_date.year, start_date.month, start_date.day)
208
208
  end
209
209
  end
@@ -53,6 +53,6 @@ class Message < ActiveRecord::Base
53
53
  end
54
54
 
55
55
  def populate_sent_at
56
- self.sent_at = Time.new
56
+ self.sent_at = Time.zone.now
57
57
  end
58
58
  end
@@ -276,8 +276,8 @@ class Participant < ActiveRecord::Base
276
276
  end
277
277
 
278
278
  def in_study?
279
- if active_membership.start_date <= Date.today &&
280
- active_membership.end_date >= Date.today
279
+ if active_membership.start_date <= Time.zone.today &&
280
+ active_membership.end_date >= Time.zone.today
281
281
  true
282
282
  else
283
283
  false
@@ -293,7 +293,7 @@ class Participant < ActiveRecord::Base
293
293
  def recent_period
294
294
  @recent_period ||= (
295
295
  # when no awake period return an empty set to allow chaining
296
- now = Time.new
296
+ now = Time.zone.now
297
297
  start_time = recent_awake_period.try(:start_time) || now
298
298
  end_time = recent_awake_period.try(:end_time) || now
299
299
 
@@ -18,7 +18,7 @@ module ParticipantMetrics
18
18
  - memberships.start_date ) ) / 604800 ) + 1
19
19
  )::int AS week, memberships.participant_id, COUNT(1)
20
20
  SQL
21
- )
21
+ )
22
22
  .merge(Participant.not_moderator)
23
23
  .merge(Membership.where(group_id: group_id))
24
24
  .group("week, memberships.participant_id")
@@ -69,7 +69,7 @@ class PhqStepping
69
69
  @skip_flag = [false]
70
70
  @assessments = assessments
71
71
  @study_start_date = study_start_date
72
- @week = ((Date.current + 1 - study_start_date).days / 1.week).ceil
72
+ @week = ((Time.zone.today + 1 - study_start_date).days / 1.week).ceil
73
73
  @upper_limit = FIRST_PERIOD_STEPPING_CUTOFF
74
74
  @upper_prev_limit = FIRST_PERIOD_STEPPING_CUTOFF
75
75
  @lower_limit = DEFAULT_PERIOD_DISCONTINUE_CUTOFF
@@ -31,7 +31,7 @@ class PhqSteppingAssessment
31
31
  date,
32
32
  score,
33
33
  study_start_date
34
- )
34
+ )
35
35
  )
36
36
  end
37
37
  converted_array
@@ -47,7 +47,7 @@ class PhqSteppingAssessment
47
47
  nil,
48
48
  false,
49
49
  assessment
50
- )
50
+ )
51
51
  )
52
52
  end
53
53
  converted_array
@@ -89,7 +89,7 @@ class TaskStatus < ActiveRecord::Base
89
89
  end
90
90
 
91
91
  def notify_today?
92
- today = Time.now
92
+ today = Time.zone.now
93
93
  start_day == ((today.to_date - membership.start_date.to_date).to_i + 1)
94
94
  end
95
95
  end
@@ -30,9 +30,11 @@ module ThinkFeelDoEngine
30
30
 
31
31
  def to_csv(csv = [])
32
32
  csv << @collector.columns
33
+ # rubocop:disable Rails/FindEach
33
34
  @collector.all.each do |s|
34
35
  csv << @collector.columns.map { |c| s[c.to_sym] }
35
36
  end
37
+ # rubocop:enable Rails/FindEach
36
38
  end
37
39
 
38
40
  private
@@ -14,8 +14,7 @@ module ThinkFeelDoEngine
14
14
  provider_id = m ? m[1] : -1
15
15
  position = m ? m[2] : -1
16
16
  video = BitCore::ContentProvider
17
- .where(id: provider_id)
18
- .first
17
+ .find_by(id: provider_id)
19
18
  .try(:source_content)
20
19
  .try(:slides)
21
20
  .try(:find_by_position, position)
@@ -41,7 +41,7 @@ class ToolNavItem
41
41
  available_content_modules
42
42
  .position_greater_than(1)
43
43
  .is_not_viz
44
- .available_by(Date.today)
44
+ .available_by(Time.zone.today)
45
45
  .order_by_position
46
46
  .latest_duplicate
47
47
  end
@@ -50,7 +50,7 @@ class ToolNavItem
50
50
  available_content_modules
51
51
  .is_not_viz
52
52
  .is_not_completed
53
- .available_on(Date.today)
53
+ .available_on(Time.zone.today)
54
54
  .exists?
55
55
  end
56
56
 
@@ -60,6 +60,6 @@ class ToolNavItem
60
60
  AvailableContentModule
61
61
  .for_tool(@tool)
62
62
  .for_participant(@participant)
63
- .is_not_terminated_on(Date.today)
63
+ .is_not_terminated_on(Time.zone.today)
64
64
  end
65
65
  end
@@ -30,7 +30,8 @@ module ThinkFeelDoEngine
30
30
  end
31
31
 
32
32
  def sortable(group)
33
- relased_on(group).to_time.to_i
33
+ date = relased_on(group)
34
+ Time.zone.local(date.year, date.month, date.day).to_i
34
35
  end
35
36
 
36
37
  def title
@@ -2,7 +2,7 @@
2
2
 
3
3
  <div id="past_activities_container">
4
4
  <% timestamps.each_with_index do |timestamp, index| %>
5
- <% start_time = Time.at(timestamp); end_time = start_time + 1.hour %>
5
+ <% start_time = Time.zone.at(timestamp); end_time = start_time + 1.hour %>
6
6
  <%= form_for(
7
7
  activity,
8
8
  url: create_path,
@@ -1,4 +1,4 @@
1
1
  # nodoc
2
2
  module ThinkFeelDoEngine
3
- VERSION = "3.19.6"
3
+ VERSION = "3.19.7"
4
4
  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.19.6
4
+ version: 3.19.7
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-07 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails