think_feel_do_engine 3.14.4 → 3.14.5

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: 5940e0066d83f969fdcd434baeae9580c5f12168
4
- data.tar.gz: c2d1eb6206d633fe3a1d198f40bd8eb0168f3cd5
3
+ metadata.gz: e59b95ffeeb1d59fe8b52cb34f6b2f4fd54b3ff5
4
+ data.tar.gz: 0d21a6b0f371c12617d5e1f865fa4d23c9855654
5
5
  SHA512:
6
- metadata.gz: ba48a876b2d94fc46545684ac2cb493ba89c122b628d846257f6b7020515eab8394c8244bfdf7ca601e19874127c26ab8c5393e88c903889e5138f4b54f06a87
7
- data.tar.gz: 0e6c44ab7e0426cd3e67af398305b132e5089368b473ef7768e46cb769c858310735dcfb42e0c8f7bb3cbc4c8596c60bbef383ad719f74a443b034e813613ac2
6
+ metadata.gz: efbc3e970c1676e73996abbd77ad07171101415778c0cc98325e8438c215e6a8a94967a684c289dd6fd5404a80fc2565488c14ef00e9b995b98ddec9c5795329
7
+ data.tar.gz: 5c14feacac0c0a5f32abbf60847202604a058b04ccf32f6b028d4bf6e6c84b49af1b7a73a5283bf4553b3a3fb734923f4187c2afe0789267b12860f93b24625b
@@ -6,6 +6,7 @@ module ThinkFeelDoEngine
6
6
  class GroupsController < ApplicationController
7
7
  before_action :authenticate_user!, :set_arm
8
8
  load_and_authorize_resource except: :edit_tasks
9
+ rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
9
10
 
10
11
  def index
11
12
  end
@@ -26,6 +27,11 @@ module ThinkFeelDoEngine
26
27
  def set_arm
27
28
  @arm = Arm.find(params[:arm_id])
28
29
  end
30
+
31
+ def record_not_found
32
+ redirect_to main_app.root_path,
33
+ alert: "The group you are looking for no longer exists."
34
+ end
29
35
  end
30
36
  end
31
37
  end
@@ -4,6 +4,8 @@ module ThinkFeelDoEngine
4
4
  class LessonViewing
5
5
  include LessonModule
6
6
 
7
+ DEFAULT_LESSON_MODULE_POSTFIX = /\/providers\/.*/
8
+
7
9
  def self.columns
8
10
  %w( participant_id lesson_id page_headers lesson_selected_at
9
11
  last_page_number_opened last_page_opened_at )
@@ -23,21 +25,17 @@ module ThinkFeelDoEngine
23
25
  .where(participant_id: participant.id, kind: "render")
24
26
  .select(:participant_id, :emitted_at, :payload)
25
27
  .to_a.select do |e|
26
- lessons.keys.include?(e.current_url.gsub(URL_ROOT_RE, ""))
28
+ lessons.keys.include?(e.current_url.gsub(URL_ROOT_RE, "")) ||
29
+ lessons_with_default_urls
30
+ .keys.include?(e.current_url.gsub(URL_ROOT_RE, ""))
27
31
  end
28
32
 
29
33
  lesson_select_events.map do |e|
30
- lesson_id = lessons[e.current_url.gsub(URL_ROOT_RE, "")]
34
+ lesson_id = lessons[e.current_url.gsub(URL_ROOT_RE, "")] ||
35
+ lessons_with_default_urls[e.current_url
36
+ .gsub(URL_ROOT_RE, "")]
31
37
  last_page_opened = last_page_opened(e, lesson_id)
32
-
33
- {
34
- participant_id: participant.study_id,
35
- lesson_id: lesson_id,
36
- page_headers: e.headers,
37
- lesson_selected_at: e.emitted_at.iso8601,
38
- last_page_number_opened: last_page_opened[:number].to_i,
39
- last_page_opened_at: last_page_opened[:opened_at].iso8601
40
- }
38
+ event_hash(participant, lesson_id, e, last_page_opened)
41
39
  end
42
40
  end.flatten
43
41
  end
@@ -55,10 +53,39 @@ module ThinkFeelDoEngine
55
53
  last_event = (lesson_events.last || first_session_event)
56
54
 
57
55
  {
58
- number: last_event.current_url[/\d+$/],
56
+ number: event_lesson_page_number(last_event),
59
57
  opened_at: last_event.emitted_at
60
58
  }
61
59
  end
60
+
61
+ def self.event_lesson_page_number(event)
62
+ if event.current_url.include? "providers"
63
+ event.current_url[/\d+$/]
64
+ else
65
+ 1
66
+ end
67
+ end
68
+
69
+ def self.lessons_with_default_urls
70
+ lessons_with_default_path = lesson_entries_map.each.map do |lesson|
71
+ default_lesson_url =
72
+ lesson[0].gsub(URL_ROOT_RE, "")
73
+ .gsub(DEFAULT_LESSON_MODULE_POSTFIX, "")
74
+ [default_lesson_url, lesson[1]]
75
+ end
76
+ Hash[lessons_with_default_path]
77
+ end
78
+
79
+ def self.event_hash(participant, lesson_id, event, last_page_opened)
80
+ {
81
+ participant_id: participant.study_id,
82
+ lesson_id: lesson_id,
83
+ page_headers: event.headers,
84
+ lesson_selected_at: event.emitted_at.iso8601,
85
+ last_page_number_opened: last_page_opened[:number].to_i,
86
+ last_page_opened_at: last_page_opened[:opened_at].iso8601
87
+ }
88
+ end
62
89
  end
63
90
  end
64
91
  end
@@ -1,4 +1,4 @@
1
1
  # nodoc
2
2
  module ThinkFeelDoEngine
3
- VERSION = "3.14.4"
3
+ VERSION = "3.14.5"
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.14.4
4
+ version: 3.14.5
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-04-04 00:00:00.000000000 Z
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails