think_feel_do_engine 3.12.7 → 3.12.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcb3c344a9fe87b672b6df1c46467251978bb9bb
4
- data.tar.gz: baba54d9b84a62b997b0ae7f54837b2e8a68a8f3
3
+ metadata.gz: 5eda6daa84e50aee599b51148c676115de55d51e
4
+ data.tar.gz: f0ae52521b0989d9cd36a0c63b5b418268743738
5
5
  SHA512:
6
- metadata.gz: 1eb26653fbd96f3397fe47b88fc03e2d0c4642fdea7de838d1e9b87cc4b3c137a14c8e06d91689225cd46b1d37e4f5152928ac9fb508669a3466ccf1702ba1f2
7
- data.tar.gz: 0535ad61ae2e474b045fc7f14edebcb67fc641b2930bc96177d10e85d1bd165b129d3f226ac67c06f3242929bd59e39e27a5f49bd197ad78bb2c7669ad4fea27
6
+ metadata.gz: 32f96a9a4ea720b696a50782e487d4204a56bf17d4e443fd8ff7eacbc9e145155e90bacd2fd66e3126c98990bd54db015286081b0ea7544416ca2c0f41c7939e
7
+ data.tar.gz: 435508a4bdd58facc163bae3c9bf1d6fadf14ec593d128610735ee35030322458c1d9a302e37ce8fa16b19a1d2a1c0957049629694e51265969e6d688dfdd0b9
@@ -20,6 +20,9 @@ module ThinkFeelDoEngine
20
20
 
21
21
  def new
22
22
  @participants = current_user.participants_for_group(@group)
23
+ redirect_to(coach_group_site_messages_path(@group),
24
+ alert: "A group must have participants in order "\
25
+ " to send site message.") if @participants.empty?
23
26
  end
24
27
 
25
28
  def create
@@ -14,9 +14,12 @@ module ThinkFeelDoEngine
14
14
 
15
15
  # condense adjacent interactions
16
16
  filtered_interactions = []
17
+
17
18
  interactions.each_with_index do |interaction, i|
18
- previous_interaction = i > 0 ? interactions[i - 1] : {}
19
- next if previous_interaction[:slide_id] == interaction[:slide_id]
19
+ previous_interaction = find_previous_interaction(interactions, i)
20
+ next if previous_interaction.nil? ||
21
+ interaction.nil? ||
22
+ previous_interaction[:slide_id] == interaction[:slide_id]
20
23
 
21
24
  next_interaction = interactions[i + 1] || {}
22
25
  filtered_interaction = interaction.clone
@@ -39,17 +42,20 @@ module ThinkFeelDoEngine
39
42
  slide_view_events(lessons, participant.id).map do |lesson_event|
40
43
  e = lesson_event[1]
41
44
  lesson_id = lesson_event[0]
42
- slides = ContentModules::LessonModule.find(lesson_id).slides
43
- slide = find_slide_by_url(slides, e.current_url)
44
-
45
- {
46
- participant_id: participant.study_id,
47
- lesson_id: lesson_id,
48
- slide_id: slide.try(:id),
49
- slide_title: slide.try(:title),
50
- slide_selected_at: e.emitted_at.try(:iso8601),
51
- slide_exited_at: next_event_at(e).try(:iso8601)
52
- }
45
+ begin
46
+ slides = ContentModules::LessonModule.find(lesson_id).slides
47
+ slide = find_slide_by_url(slides, e.current_url)
48
+ {
49
+ participant_id: participant.study_id,
50
+ lesson_id: lesson_id,
51
+ slide_id: slide.try(:id),
52
+ slide_title: slide.try(:title),
53
+ slide_selected_at: e.emitted_at.try(:iso8601),
54
+ slide_exited_at: next_event_at(e).try(:iso8601)
55
+ }
56
+ rescue ActiveRecord::RecordNotFound
57
+ lesson_module_not_found(participant, lesson_id) if defined?(Raven)
58
+ end
53
59
  end
54
60
  end.flatten
55
61
  end
@@ -87,7 +93,20 @@ module ThinkFeelDoEngine
87
93
  slide_position = url[/\d+$/].to_i
88
94
  end
89
95
 
90
- slides.find_by_position(slide_position)
96
+ slides.find_by_position(slide_position) unless slides.empty?
97
+ end
98
+
99
+ def self.lesson_module_not_found(participant, lesson_id)
100
+ Raven.capture_message "No slides found for lesson found",
101
+ extra: {
102
+ participant_id: participant.try(:id),
103
+ study_id: participant.try(:study_id),
104
+ lesson_id: lesson_id
105
+ }
106
+ end
107
+
108
+ def self.find_previous_interaction(interactions, index)
109
+ index > 0 ? interactions[index - 1] : {}
91
110
  end
92
111
  end
93
112
  end
@@ -1,4 +1,4 @@
1
1
  # nodoc
2
2
  module ThinkFeelDoEngine
3
- VERSION = "3.12.7"
3
+ VERSION = "3.12.8"
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.12.7
4
+ version: 3.12.8
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-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails