rails_admin_charts 0.0.8 → 0.0.9
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 +4 -4
- data/README.md +1 -1
- data/lib/rails_admin_charts.rb +3 -2
- data/lib/rails_admin_charts/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db0b3e972b9cfcab8a3b6f33ad7b2539774dfd8f
|
4
|
+
data.tar.gz: 67db7414135137a4ef09611433d14bae39d2a5da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4b3dc2e3dccbe0a776c5b33920f7d2c1aad5fd2818bc0c426d174a7668ca7c3e2276c782722adb5f49fd9a679bc58d59789514916e52f994a36e306ad2ad80d
|
7
|
+
data.tar.gz: 811669e9900a626f72d42e0baad0d576d2cf4f5bc75439b931b2be20b7c9759caebb6b3601d59ba8eaadb4c4bbe079fd873d0666ac4b360ee59645cbe82104c8
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ Run:
|
|
10
10
|
|
11
11
|
$ bundle install
|
12
12
|
|
13
|
-
This will include the lazy_high_charts gem and add the assets to the pipeline.
|
13
|
+
This will include the lazy_high_charts gem and add the assets to the pipeline. NB: remember to recompile assets if adding this to staging or production environments.
|
14
14
|
|
15
15
|
In your RailsAdmin initializer (`app/config/initializers/rails_admin.rb`), enable the action by adding:
|
16
16
|
|
data/lib/rails_admin_charts.rb
CHANGED
@@ -9,12 +9,13 @@ module RailsAdminCharts
|
|
9
9
|
module ClassMethods
|
10
10
|
def total_records_since(since = 30.days.ago)
|
11
11
|
totals, before_count = self.group('DATE(created_at)').count, self.where('created_at < ?', since.to_date).count
|
12
|
-
|
12
|
+
# TODO separate MySQL/Postgres approaches using ActiveRecord::Base.connection.adapter_name or check hash key is_a? String/Date
|
13
|
+
(since.to_date..Date.today).each_with_object([]) { |day, a| a << (a.last || before_count) + (totals[day] || totals[day.to_s] || 0) }
|
13
14
|
end
|
14
15
|
|
15
16
|
def delta_records_since(since = 30.days.ago)
|
16
17
|
deltas = self.group('DATE(created_at)').count
|
17
|
-
(since.to_date..Date.today).map { |date| deltas[date.to_s] || 0 }
|
18
|
+
(since.to_date..Date.today).map { |date| deltas[date] || deltas[date.to_s] || 0 }
|
18
19
|
end
|
19
20
|
|
20
21
|
def graph_data(since=30.days.ago)
|