reparty 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +5 -0
- data/app/views/report_mailer/_active_record.html.erb +8 -3
- data/lib/reparty/report/active_record.rb +13 -3
- data/lib/reparty/version.rb +1 -1
- data/lib/reparty.rb +0 -1
- metadata +3 -4
- data/lib/reparty/railties.rb +0 -7
data/History.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
<table width="500">
|
2
2
|
<tr>
|
3
|
-
<td align="left"
|
4
|
-
|
3
|
+
<td align="left">
|
4
|
+
<h3 style="margin:0"><%= report.title %></h3>
|
5
|
+
<ul>
|
6
|
+
<li>Total <%= report.model.to_s.pluralize %>: <%= number_with_delimiter(report.total) %></li>
|
7
|
+
<li><%= report.model.to_s.pluralize %> created yesterday: <%= number_with_delimiter(report.yesterday) %></li>
|
8
|
+
</ul>
|
9
|
+
</td>
|
5
10
|
</tr>
|
6
11
|
<tr>
|
7
|
-
<td
|
12
|
+
<td align="center"><%= image_tag attachments["#{report.hash}.png"].url, align: "center" %></td>
|
8
13
|
</tr>
|
9
14
|
</table>
|
@@ -9,7 +9,7 @@ module Reparty
|
|
9
9
|
raise "Report::ActiveRecord: model undefined" unless args.first.is_a?(Symbol)
|
10
10
|
@model = Kernel.const_get(args.first.to_s.capitalize)
|
11
11
|
|
12
|
-
@operation = args.fetch(
|
12
|
+
@operation = args.fetch(1, :count)
|
13
13
|
@field = :created_at
|
14
14
|
|
15
15
|
if args.last.is_a?(Hash)
|
@@ -26,11 +26,21 @@ module Reparty
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def daily_dataset
|
29
|
-
|
29
|
+
if @operation == :total
|
30
|
+
7.downto(1).map { |x| @model.where("#{@field.to_s} < ?", DateTime.now-x).send(:count, @field) }
|
31
|
+
else
|
32
|
+
7.downto(1).map { |x| @model.where("DATE(#{@field.to_s}) = ?", DateTime.now-x).send(@operation, @field) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def yesterday
|
37
|
+
op = @operation == :total ? :count : @operation
|
38
|
+
@model.where("DATE(#{@field.to_s}) = ?", DateTime.now-1).send(op, @field)
|
30
39
|
end
|
31
40
|
|
32
41
|
def total
|
33
|
-
@
|
42
|
+
op = @operation == :total ? :count : @operation
|
43
|
+
@model.send(op, @field)
|
34
44
|
end
|
35
45
|
end
|
36
46
|
end
|
data/lib/reparty/version.rb
CHANGED
data/lib/reparty.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: reparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tim Dorr
|
@@ -211,7 +211,6 @@ files:
|
|
211
211
|
- lib/reparty/config.rb
|
212
212
|
- lib/reparty/email.rb
|
213
213
|
- lib/reparty/engine.rb
|
214
|
-
- lib/reparty/railties.rb
|
215
214
|
- lib/reparty/report.rb
|
216
215
|
- lib/reparty/report/active_record.rb
|
217
216
|
- lib/reparty/version.rb
|
@@ -236,7 +235,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
236
235
|
- !ruby/object:Gem::Version
|
237
236
|
segments:
|
238
237
|
- 0
|
239
|
-
hash:
|
238
|
+
hash: 364078878128042041
|
240
239
|
version: '0'
|
241
240
|
none: false
|
242
241
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -245,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
244
|
- !ruby/object:Gem::Version
|
246
245
|
segments:
|
247
246
|
- 0
|
248
|
-
hash:
|
247
|
+
hash: 364078878128042041
|
249
248
|
version: '0'
|
250
249
|
none: false
|
251
250
|
requirements: []
|