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 CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.1.2
2
+
3
+ - Accidentally included rake task twice by defining both an Engine and a Railtie
4
+ - Add :total to ActiveRecord report types
5
+
1
6
  ## 0.1.0
2
7
 
3
8
  - Initial release
@@ -1,9 +1,14 @@
1
1
  <table width="500">
2
2
  <tr>
3
- <td align="left"><h3 style="margin:0"><%= report.title %></h3></td>
4
- <td align="right">Total <%= report.model.to_s.pluralize %>: <%= number_with_delimiter(report.total) %></td>
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 colspan="2"><%= image_tag attachments["#{report.hash}.png"].url, align: "center" %></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(2, :count)
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
- 7.downto(1).map { |x| @model.where("DATE(#{@field.to_s}) = ?", (DateTime.now.at_midnight-x).strftime('%Y-%m-%d')).send(@operation, @field) }
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
- @model.send(@operation, @field)
42
+ op = @operation == :total ? :count : @operation
43
+ @model.send(op, @field)
34
44
  end
35
45
  end
36
46
  end
@@ -1,3 +1,3 @@
1
1
  module Reparty
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/reparty.rb CHANGED
@@ -6,7 +6,6 @@ require "reparty/report/active_record"
6
6
  require "reparty/email"
7
7
 
8
8
  require "reparty/engine"
9
- require "reparty/railties"
10
9
 
11
10
  module Reparty
12
11
  class << self
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: reparty
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
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: 3863277872832140931
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: 3863277872832140931
247
+ hash: 364078878128042041
249
248
  version: '0'
250
249
  none: false
251
250
  requirements: []
@@ -1,7 +0,0 @@
1
- module Reparty
2
- class Railtie < Rails::Railtie
3
- rake_tasks do
4
- load "tasks/reparty.rake"
5
- end
6
- end
7
- end