think_feel_do_engine 3.12.2 → 3.12.3

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: d8e4d81a41dca2e08ff40240e59b0d66c127831e
4
- data.tar.gz: 9ea3ae94bbe6ed2dedd7a57cdfda73369b8d5caf
3
+ metadata.gz: 294cb733b7d6aaab9041418769aadaf0af82f003
4
+ data.tar.gz: ea4ca81298e6edfc3f6d92fcd559910c195c71ee
5
5
  SHA512:
6
- metadata.gz: f655994ab605059ff192c8afb13063446349629bd2a1f288f3d15c68d565825eabd6f72aa87c306398c8860c44c3004065a1c2970525f1c512a12049ac97fdee
7
- data.tar.gz: 557b7979e7bd05a5ee513458cdb55b5815ed2871cae675c5ab28549547f5d6847c528c4a49d0a71897afd79914fe05fb8cc08cf6eb267a6b3336e3299498b5ba
6
+ metadata.gz: d82dfd3f54e0bbb82f27c16dd77f8e33d184a71df5598f5bba85c627e6988855645d857e06049f07b789277615fff3aed79b27a2c9c0df298cf2790e6d10abc3
7
+ data.tar.gz: 4c7a4ae3116ef79dd1495b5ef419b48db9482494eafdede5519f9aa5ce01550d69eb2ab7a270634e10ef3d75435e524cdf787f608588adca5b494347842a8882
data/Rakefile CHANGED
@@ -25,9 +25,9 @@ end
25
25
 
26
26
  require "jshintrb/jshinttask"
27
27
  Jshintrb::JshintTask.new :jshint do |t|
28
- t.pattern = "spec/dummy/spec/javascripts/**/*.js"
28
+ t.pattern = %w( spec/dummy/spec/javascripts/**/*.js app/assets/javascripts/think_feel_do_engine/**/mood.js )
29
29
  t.options = :defaults
30
- t.globals = ["$".to_sym, :spyOn, :afterEach, :beforeEach, :describe, :expect, :it, :jasmine, :sc]
30
+ t.globals = ["$".to_sym, :spyOn, :afterEach, :beforeEach, :describe, :expect, :it, :jasmine, :sc, :Graph, :appendDateRange, :columnChart, :d3, :moment]
31
31
  end
32
32
 
33
33
  require "rubocop/rake_task"
@@ -44,6 +44,6 @@ task :default do
44
44
  Rake::Task["brakeman"].invoke
45
45
  Rake::Task["jshint"].invoke
46
46
  Rake::Task["rubocop"].invoke
47
- Rake::Task["spec"].invoke
48
47
  Rake::Task["js_spec"].invoke
48
+ Rake::Task["spec"].invoke
49
49
  end
@@ -0,0 +1,63 @@
1
+ (function () {
2
+ 'use strict';
3
+
4
+ sc.calcStartOfDay = function(date) {
5
+ return moment(date.day, 'YYYY-MM-DDTHH:mm:ss.sssZ').startOf('day')._d;
6
+ };
7
+
8
+ sc.drawMoodEmotionGraphs = function(graphParameters) {
9
+ var NOTES = '*Click each day for more information.';
10
+
11
+ function clearContainers() {
12
+ $('div#mood, div#mood-legend, div#emotions, div#emotion-legend')
13
+ .empty();
14
+ }
15
+
16
+ function drawMoodViz(graphParameters) {
17
+ var GRAPH_DIV_ID = '#mood';
18
+ var GRAPH_TITLE = 'Mood*';
19
+ var LEGEND = [['Mood', '#4682B4'], ['Daily Average', 'green']];
20
+ var LEGEND_DIV_ID = '#mood-legend';
21
+ var PIXEL_HEIGHT = 300;
22
+ var Y_MAX = 10;
23
+ var Y_MIN = 0;
24
+ var YLABEL = 'mood';
25
+
26
+ d3.select(GRAPH_DIV_ID)
27
+ .datum(graphParameters.moodData)
28
+ .call(columnChart(graphParameters.startDate, graphParameters.endDate, Y_MIN, Y_MAX, GRAPH_TITLE, YLABEL)
29
+ .width(graphParameters.graphWidth)
30
+ .height(PIXEL_HEIGHT)
31
+ .x(function(date, i) {
32
+ return sc.calcStartOfDay(date);
33
+ })
34
+ .y(function(d, i) {
35
+ return d.intensity;
36
+ })
37
+ .drawLegend(LEGEND_DIV_ID, LEGEND, [NOTES]));
38
+ }
39
+
40
+ function drawEmotionViz(graphParameters) {
41
+ var GRAPH_DIV_ID = '#emotions';
42
+ var GRAPH_TITLE = 'Positive and Negative Emotions*';
43
+ var LEGEND = [['Positive', '#4682B4'], ['Negative', '#A52A2A'], ['Daily Average', 'green']];
44
+ var LEGEND_DIV_ID = '#emotion-legend';
45
+ var PIXEL_HEIGHT = 400;
46
+ var Y_MAX = 10;
47
+ var Y_MIN = -10;
48
+ var YLABEL = 'Intensity';
49
+
50
+ d3.select(GRAPH_DIV_ID)
51
+ .datum(graphParameters.emotionsData)
52
+ .call(columnChart(graphParameters.startDate, graphParameters.endDate, Y_MIN, Y_MAX, GRAPH_TITLE, YLABEL)
53
+ .width(graphParameters.graphWidth)
54
+ .height(PIXEL_HEIGHT)
55
+ .drawLegend(LEGEND_DIV_ID, LEGEND, [NOTES]));
56
+ }
57
+
58
+ clearContainers();
59
+ drawMoodViz(graphParameters);
60
+ drawEmotionViz(graphParameters);
61
+ return appendDateRange(graphParameters);
62
+ };
63
+ })();
@@ -355,8 +355,7 @@ class Activity < ActiveRecord::Base
355
355
  end
356
356
 
357
357
  def set_end_time
358
- unless start_time.nil?
359
- self.end_time = start_time + 1.hour
360
- end
358
+ return unless end_time.nil? && start_time.present?
359
+ self.end_time = start_time + 1.hour
361
360
  end
362
- end
361
+ end
@@ -32,7 +32,7 @@ class DeliveredMessage < ActiveRecord::Base
32
32
  if recipient.instance_of? User
33
33
  ThinkFeelDoEngine::MessageNotifications
34
34
  .new_for_coach(recipient, sender.active_group)
35
- .deliver
35
+ .deliver_now
36
36
  elsif recipient.notify_by_sms?
37
37
  MessageSmsNotification
38
38
  .new(
@@ -42,7 +42,7 @@ class DeliveredMessage < ActiveRecord::Base
42
42
  else
43
43
  ThinkFeelDoEngine::MessageNotifications
44
44
  .new_for_participant(recipient)
45
- .deliver
45
+ .deliver_now
46
46
  end
47
47
  rescue => exception
48
48
  ::Raven.capture_message(exception)
data/app/models/group.rb CHANGED
@@ -42,8 +42,10 @@ class Group < ActiveRecord::Base
42
42
  membership
43
43
  .participant
44
44
  .thoughts
45
- .where(thoughts[:created_at].gteq(week_start_day(week_number)))
46
- .where(thoughts[:created_at].lt(week_end_day(week_number)))
45
+ .where(thoughts[:created_at]
46
+ .gteq(membership.week_start_day(week_number)))
47
+ .where(thoughts[:created_at]
48
+ .lt(membership.week_end_day(week_number)))
47
49
  end.map(&:count).sum
48
50
  end
49
51
 
@@ -55,8 +57,8 @@ class Group < ActiveRecord::Base
55
57
  .participant
56
58
  .activities
57
59
  .in_the_past
58
- .where(activities[:created_at].gteq(week_start_day(week_number)))
59
- .where(activities[:created_at].lt(week_end_day(week_number)))
60
+ .where(activities[:start_time]
61
+ .gteq(membership.week_start_day(week_number)))
60
62
  end.map(&:count).sum
61
63
  end
62
64
 
@@ -68,8 +70,8 @@ class Group < ActiveRecord::Base
68
70
  .participant
69
71
  .activities
70
72
  .unscheduled_or_in_the_future
71
- .where(activities[:created_at].gteq(week_start_day(week_number)))
72
- .where(activities[:created_at].lt(week_end_day(week_number)))
73
+ .where(activities[:start_time]
74
+ .lt(membership.week_end_day(week_number)))
73
75
  end.map(&:count).sum
74
76
  end
75
77
 
@@ -80,9 +82,9 @@ class Group < ActiveRecord::Base
80
82
  SocialNetworking::Goal
81
83
  .where(participant: membership.participant)
82
84
  .where(social_networking_goals[:created_at]
83
- .gteq(week_start_day(week_number)))
85
+ .gteq(membership.week_start_day(week_number)))
84
86
  .where(social_networking_goals[:created_at]
85
- .lt(week_end_day(week_number)))
87
+ .lt(membership.week_end_day(week_number)))
86
88
  end.map(&:count).sum
87
89
  end
88
90
 
@@ -93,9 +95,9 @@ class Group < ActiveRecord::Base
93
95
  SocialNetworking::Comment
94
96
  .where(participant: membership.participant)
95
97
  .where(social_networking_comments[:created_at]
96
- .gteq(week_start_day(week_number)))
98
+ .gteq(membership.week_start_day(week_number)))
97
99
  .where(social_networking_comments[:created_at]
98
- .lt(week_end_day(week_number)))
100
+ .lt(membership.week_end_day(week_number)))
99
101
  end.map(&:count).sum
100
102
  end
101
103
 
@@ -107,9 +109,9 @@ class Group < ActiveRecord::Base
107
109
  SocialNetworking::OnTheMindStatement
108
110
  .where(participant: membership.participant)
109
111
  .where(social_networking_on_the_mind_statements[:created_at]
110
- .gteq(week_start_day(week_number)))
112
+ .gteq(membership.week_start_day(week_number)))
111
113
  .where(social_networking_on_the_mind_statements[:created_at]
112
- .lt(week_end_day(week_number)))
114
+ .lt(membership.week_end_day(week_number)))
113
115
  end.map(&:count).sum
114
116
  end
115
117
 
@@ -121,24 +123,9 @@ class Group < ActiveRecord::Base
121
123
  SocialNetworking::Like
122
124
  .where(participant: membership.participant)
123
125
  .where(social_networking_likes[:created_at]
124
- .gteq(week_start_day(week_number)))
126
+ .gteq(membership.week_start_day(week_number)))
125
127
  .where(social_networking_likes[:created_at]
126
- .lt(week_end_day(week_number)))
128
+ .lt(membership.week_end_day(week_number)))
127
129
  end.map(&:count).sum
128
130
  end
129
-
130
- private
131
-
132
- # Returns the earliest start date of all the group's memberships
133
- def start_date
134
- memberships.order(start_date: :asc).first.start_date
135
- end
136
-
137
- def week_start_day(week_number)
138
- start_date + ((week_number - 1) * 7).days
139
- end
140
-
141
- def week_end_day(week_number)
142
- start_date + (week_number * 7).days
143
- end
144
131
  end
@@ -154,6 +154,14 @@ class Membership < ActiveRecord::Base
154
154
  update_columns(end_date: Date.current - 1.day, is_complete: true)
155
155
  end
156
156
 
157
+ def week_start_day(week_number)
158
+ start_date_with_zone + ((week_number - 1) * 7).days
159
+ end
160
+
161
+ def week_end_day(week_number)
162
+ start_date_with_zone + (week_number * 7).days
163
+ end
164
+
157
165
  private
158
166
 
159
167
  def create_task_statuses
@@ -183,17 +191,13 @@ class Membership < ActiveRecord::Base
183
191
  errors.add :is_complete, "cannot be set to true for end dates in the future"
184
192
  end
185
193
 
186
- def week_start_day(week_number)
187
- start_date + ((week_number - 1) * 7).days
188
- end
189
-
190
- def week_end_day(week_number)
191
- start_date + (week_number * 7).days
192
- end
193
-
194
194
  def not_ending_in_the_past
195
195
  return unless end_date && end_date_changed? && end_date < Date.current
196
196
 
197
197
  errors.add :end_date, "must not be in the past"
198
198
  end
199
+
200
+ def start_date_with_zone
201
+ start_date.to_time
202
+ end
199
203
  end
@@ -319,7 +319,7 @@ class Participant < ActiveRecord::Base
319
319
 
320
320
  def mood_rating_daily_averages
321
321
  averaged_ratings = []
322
- daily_ratings = moods.group_by { |mood| mood.created_at.to_date }
322
+ daily_ratings = moods.group_by(&:created_at)
323
323
  # rubocop:disable all
324
324
  daily_ratings.each do |day, moods_array|
325
325
  # rubocop:enable all
@@ -31,45 +31,7 @@
31
31
  var activationDate = activation("<%= current_participant.created_at %>")
32
32
 
33
33
  var graphParameters = new Graph(<%= sanitize(mood_ratings.to_json) %>, <%= sanitize(emotional_ratings.to_json) %>, null, $("#viz-container"));
34
- var yLabel = "Intensity"
35
34
 
36
- sc.drawGraphs = function() {
37
- var emotionGraphTitle,
38
- emotionLegendJSON,
39
- emotionLegendNotes,
40
- moodGraphTitle,
41
- moodLegendJSON,
42
- moodLegendNotes;
43
-
44
- $("div#mood, div#mood-legend, div#emotions, div#emotion-legend").empty();
45
-
46
- // mood viz
47
- moodGraphTitle = "Mood*";
48
- moodLegendJSON = [["Mood", "#4682B4"], ["Daily Average", "green"]];
49
- moodLegendNotes = ["*Click each day for more information."];
50
- d3.select("#mood")
51
- .datum(graphParameters.moodData)
52
- .call(columnChart(graphParameters.startDate, graphParameters.endDate, 0, 10, moodGraphTitle, "mood")
53
- .width(graphParameters.graphWidth)
54
- .height(300)
55
- .x(function(d, i) { return moment(new Date(d.day)).startOf("day")._d; })
56
- .y(function(d, i) { return d.intensity; })
57
- .drawLegend("#mood-legend", moodLegendJSON, moodLegendNotes));
58
-
59
- // emotion viz
60
- emotionGraphTitle = "Positive and Negative Emotions*";
61
- emotionLegendJSON = [["Positive", "#4682B4"], ["Negative", "#A52A2A"], ["Daily Average", "green"]];
62
- emotionLegendNotes = ["*Click each day for more information."];
63
- d3.select("#emotions")
64
- .datum(graphParameters.emotionsData)
65
- .call(columnChart(graphParameters.startDate, graphParameters.endDate, -10, 10, emotionGraphTitle, yLabel)
66
- .width(graphParameters.graphWidth)
67
- .height(400)
68
- .drawLegend("#emotion-legend", emotionLegendJSON, emotionLegendNotes));
69
-
70
- return appendDateRange(graphParameters);
71
- };
72
-
73
- sc.drawGraphs();
35
+ sc.drawMoodEmotionGraphs(graphParameters);
74
36
  sc.filterEmotionMoodViz(graphParameters);
75
37
  </script>
@@ -1,4 +1,4 @@
1
1
  # nodoc
2
2
  module ThinkFeelDoEngine
3
- VERSION = "3.12.2"
3
+ VERSION = "3.12.3"
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.2
4
+ version: 3.12.3
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-02-17 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -268,14 +268,14 @@ dependencies:
268
268
  requirements:
269
269
  - - "~>"
270
270
  - !ruby/object:Gem::Version
271
- version: '1.6'
271
+ version: '1.8'
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - "~>"
277
277
  - !ruby/object:Gem::Version
278
- version: '1.6'
278
+ version: '1.8'
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: database_cleaner
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -349,6 +349,7 @@ files:
349
349
  - app/assets/javascripts/think_feel_do_engine/event_capture/init.js
350
350
  - app/assets/javascripts/think_feel_do_engine/feel/emotion_mood_viz.js
351
351
  - app/assets/javascripts/think_feel_do_engine/feel/emotions.js
352
+ - app/assets/javascripts/think_feel_do_engine/feel/mood.js
352
353
  - app/assets/javascripts/think_feel_do_engine/feel/timeago.js
353
354
  - app/assets/javascripts/think_feel_do_engine/forms/multi_page.js.erb
354
355
  - app/assets/javascripts/think_feel_do_engine/forms/multi_page_thought.js.erb