effective_reports 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/report.rb +37 -0
- data/app/views/admin/reports/_report.html.haml +4 -0
- data/lib/effective_reports/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d17b2b5fa09430885fdf6cbb66abfd0e082189ad50a23b2a4787d4db6d6a9a3
|
4
|
+
data.tar.gz: f5b5d85079e66a31df655e261723c20f186afbb5e5959d85cc19460e8a24714e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e415977ddf36b30114f8bf9c2646fb8c71fa6b8e735208e94baf7b76ff58374f5a46dfb7bb1e7ad6833f3947afe938ac7e5c0a69efd12b058f17c0b7c590c61
|
7
|
+
data.tar.gz: e80d08319c8f0f99afe66da49f73c2943beec2f573ff9475724c17ff8b42eaff909cf798a6efbc163bbfede1f215bd1aab4ec8635dc94b806a89a8fe001fd19e
|
@@ -116,6 +116,43 @@ module Effective
|
|
116
116
|
scopes
|
117
117
|
end
|
118
118
|
|
119
|
+
# Return a string you can copy and paste into a seeds file
|
120
|
+
def seeds
|
121
|
+
seeds = [
|
122
|
+
"report = Effective::Report.where(title: \"#{title}\", reportable_class_name: \"#{reportable_class_name}\").first_or_initialize",
|
123
|
+
("report.assign_attributes(description: \"#{description}\")" if description.present?),
|
124
|
+
].compact
|
125
|
+
|
126
|
+
seeds += report_columns.map do |column|
|
127
|
+
attributes = column.dup.attributes.except('name', 'report_id', 'position', 'as').compact
|
128
|
+
attributes.delete('filter') unless attributes['filter']
|
129
|
+
|
130
|
+
if attributes.present?
|
131
|
+
attributes = attributes.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')
|
132
|
+
"report.col(:#{column.name}, #{attributes})"
|
133
|
+
else
|
134
|
+
"report.col(:#{column.name})"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
seeds += report_scopes.map do |scope|
|
139
|
+
attributes = scope.dup.attributes.except('name', 'report_id', 'position').compact
|
140
|
+
|
141
|
+
if attributes.present?
|
142
|
+
attributes = attributes.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')
|
143
|
+
"report.scope(:#{scope.name}, #{attributes})"
|
144
|
+
else
|
145
|
+
"report.scope(:#{scope.name})"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
seeds += [
|
150
|
+
"report.save!"
|
151
|
+
]
|
152
|
+
|
153
|
+
seeds.join("\n")
|
154
|
+
end
|
155
|
+
|
119
156
|
def duplicate
|
120
157
|
Effective::Report.new(attributes.except('id', 'updated_at', 'created_at')).tap do |report|
|
121
158
|
report.title = title + ' (Copy)'
|
@@ -14,6 +14,10 @@
|
|
14
14
|
= collapse('Show SQL') do
|
15
15
|
%p= report.collection.to_sql
|
16
16
|
|
17
|
+
= collapse('Show Seeds') do
|
18
|
+
%small
|
19
|
+
%pre= report.seeds
|
20
|
+
|
17
21
|
- if (notifications = report.try(:notifications)).present?
|
18
22
|
%p.mt-3
|
19
23
|
The following notifications are sent based on this report:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_reports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|