totalizer 0.1.4 → 0.1.5

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: 6ba8534b0f4785c3d5700aaf41311d25eb66b9ca
4
- data.tar.gz: 4f3ca823d0b686540d84ef0e685fc6bb588ed4a3
3
+ metadata.gz: 89db1d11fe08b6b477c7fc209ddb24f7537aec4e
4
+ data.tar.gz: fcd8cb2f3df52526a4c759c4e993792f79296fa2
5
5
  SHA512:
6
- metadata.gz: c03d5adbffb5dc526211871c8dc406449cd3e971601af888470d1fe05f9ab350b6f526a59e8ebbf4ea73ab567c40d3a042be61aa2d44efd46a4e5522254c25f1
7
- data.tar.gz: d40929ed3beb818d8a5e767e77ba3fd46bb0d850ad3253e75407ee7ddfc99d0869fa16df7d96ad18904a870ecb158ef8e0cd932b63ef61c279a8509704268a7f
6
+ metadata.gz: ec66b19d81c43e9fa88adab5f90b475fb4937f93f358048a194fc7bd177b413e303675a7256bf1135305c91dcd944701dc7d5846706eee3c060517e394aef022
7
+ data.tar.gz: 7bf3ff04481892b39383f66a06f7b06e01b1b8c67fd9041d3b0d289b5d3194402ea34370eee77da8d37941f0f8b1916e87d256615f4c4b9972f88a8b9e767385
data/README.md CHANGED
@@ -185,6 +185,9 @@ You can also run a single rake task every day which will run execute the daily
185
185
  task each time and execute the weekly task on a defined week day which by
186
186
  default is Monday.
187
187
 
188
+ This is handy for things like [Heroku Scheduler](https://elements.heroku.com/addons/scheduler)
189
+ where you can only schedule daily tasks.
190
+
188
191
  ```
189
192
  $ rake totalizer:combined
190
193
  ```
@@ -23,7 +23,7 @@ module Totalizer
23
23
  end
24
24
 
25
25
  def activity
26
- activity_metric = Totalizer::Metric.new self.activity_metric.attributes.merge(date: date, duration: duration, map: 'id')
26
+ activity_metric = Totalizer::Metric.new self.activity_metric.attributes.merge(date: date, duration: duration)
27
27
  ActivityMessage.new(activity_metric, duration)
28
28
  end
29
29
 
@@ -32,7 +32,7 @@ module Totalizer
32
32
  class ActivityMessage < MetricMessage
33
33
  def initialize metric, duration
34
34
  super
35
- self.description = "Key activities this period (with rate of change)"
35
+ self.description = "Did key activity this period (with rate of change)"
36
36
  end
37
37
  end
38
38
 
@@ -54,7 +54,7 @@ module Totalizer
54
54
  private
55
55
 
56
56
  def calculate where
57
- model.where(filter).where(where).map { |object| object.send(map) }.uniq
57
+ model.where(filter).where(where).map{ |object| object.send(map) }.uniq
58
58
  end
59
59
 
60
60
  def validate_attributes!
@@ -1,3 +1,3 @@
1
1
  module Totalizer
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -64,7 +64,7 @@ describe Totalizer::Factory do
64
64
 
65
65
  describe "Activity" do
66
66
  it "returns text" do
67
- expect(factory.activity.text).to eq "Last 7 days: 2 (∆ 50%)"
67
+ expect(factory.activity.text).to eq "Last 7 days: 2 (∆ 25%)"
68
68
  end
69
69
  end
70
70
 
@@ -85,6 +85,20 @@ describe Totalizer::Metric do
85
85
  expect(metric.rate).to eq 0
86
86
  end
87
87
  end
88
+
89
+ describe 'with multiple records' do
90
+ let(:metric) { Totalizer::Metric.new(model: Post, map: 'user_id') }
91
+ before do
92
+ FactoryGirl.create :post, user_id: user_1.id, created_at: 1.days.ago
93
+ FactoryGirl.create :post, user_id: user_1.id, created_at: 2.days.ago
94
+ FactoryGirl.create :post, user_id: user_2.id, created_at: 2.days.ago
95
+ FactoryGirl.create :post, user_id: user_3.id, created_at: 3.days.ago
96
+ end
97
+
98
+ it "counts the unique map ids for duration" do
99
+ expect(metric.value).to eq 3
100
+ end
101
+ end
88
102
  end
89
103
 
90
104
  describe "Filter" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totalizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dijkstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-02 00:00:00.000000000 Z
11
+ date: 2016-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler