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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bab0b4e74a447c50b3df13ac958875e0e0e8cb9bc450ccc7909dc4a76346f12c
4
- data.tar.gz: 382eec07c9c0cff2acf158189e7efa6d206d7788abb71b6a8e781052163d1339
3
+ metadata.gz: 6d17b2b5fa09430885fdf6cbb66abfd0e082189ad50a23b2a4787d4db6d6a9a3
4
+ data.tar.gz: f5b5d85079e66a31df655e261723c20f186afbb5e5959d85cc19460e8a24714e
5
5
  SHA512:
6
- metadata.gz: 581576fbcb15d9f3245ca22643b21d9ea715a6d3ada1c908d17154d4eb09875b27329037fd43079cf63d27072f3455c7d8d9deba562b555cd86079cf9a2d8d51
7
- data.tar.gz: ba9f71ac16a7ca0cc6f4cf45b8feee1cac60be99d12b782458e8c8ff01c9425a84ebf44c4241016ecea3b47880592d6a4b41ac10320bab2c2bfaee37c137a78c
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:
@@ -1,3 +1,3 @@
1
1
  module EffectiveReports
2
- VERSION = '0.4.5'.freeze
2
+ VERSION = '0.4.6'.freeze
3
3
  end
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.5
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-02-28 00:00:00.000000000 Z
11
+ date: 2024-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails