gazer 0.3.0 → 0.3.1
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/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/gzr/commands/dashboard/cat.rb +1 -0
- data/lib/gzr/commands/dashboard.rb +3 -1
- data/lib/gzr/commands/folder/export.rb +2 -0
- data/lib/gzr/commands/folder.rb +2 -0
- data/lib/gzr/commands/look/cat.rb +1 -0
- data/lib/gzr/commands/look.rb +2 -0
- data/lib/gzr/modules/dashboard.rb +67 -0
- data/lib/gzr/modules/look.rb +18 -1
- data/lib/gzr/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: 0aa31037c34f27e9ecbb6a167a6fa7b4ff0b7c6862ff5a677221f7a7e3cf6fed
|
4
|
+
data.tar.gz: 44baf0168715b3465d54da5d45d8a642d476a4a087d6970b978d81029ec8321d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 442f59d6d7f1654b423df189701f3061dea572cdf97e452197a45d29e65c61509aac47af22cb24b1510b82b52c7e37377dad3901eeb4480db13bef384781f5b2
|
7
|
+
data.tar.gz: 9adda3d7707fdbcf7beb6e488cf69ecfe32a3d4743aa4070c57b530f5ce4255c1cd6464d810b78deb95efc038c368ac75be472f273af75e5ac2f56113917ea95
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.3.1](https://github.com/looker-open-source/gzr/compare/v0.3.0...v0.3.1) (2023-04-20)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Add --trim option for dashboard cat, look cat, and folder export commands ([#178](https://github.com/looker-open-source/gzr/issues/178)) ([3173796](https://github.com/looker-open-source/gzr/commit/317379600803cfb92d223980930c0831fe8c247d))
|
9
|
+
|
3
10
|
## [0.3.0](https://github.com/looker-open-source/gzr/compare/v0.2.60...v0.3.0) (2023-04-13)
|
4
11
|
|
5
12
|
|
data/Gemfile.lock
CHANGED
@@ -53,7 +53,9 @@ module Gzr
|
|
53
53
|
method_option :transform, type: :string,
|
54
54
|
desc: 'Fully-qualified path to a JSON file describing the transformations to apply'
|
55
55
|
method_option :simple_filename, type: :boolean,
|
56
|
-
|
56
|
+
desc: 'Use simple filename for output (Dashboard_<id>.json)'
|
57
|
+
method_option :trim, type: :boolean,
|
58
|
+
desc: 'Trim output to minimal set of fields for later import'
|
57
59
|
def cat(dashboard_id)
|
58
60
|
if options[:help]
|
59
61
|
invoke :help, ['cat']
|
@@ -99,12 +99,14 @@ module Gzr
|
|
99
99
|
end
|
100
100
|
folder[:looks].each do |l|
|
101
101
|
look = cat_look(l[:id])
|
102
|
+
look = trim_look(look) if @options[:trim]
|
102
103
|
write_file("Look_#{look[:id]}_#{look[:title]}.json", base, path) do |f|
|
103
104
|
f.write JSON.pretty_generate(look)
|
104
105
|
end
|
105
106
|
end
|
106
107
|
folder[:dashboards].each do |d|
|
107
108
|
data = cat_dashboard(d[:id])
|
109
|
+
data = trim_dashboard(data) if @options[:trim]
|
108
110
|
write_file("Dashboard_#{data[:id]}_#{data[:title]}.json", base, path) do |f|
|
109
111
|
f.write JSON.pretty_generate(data)
|
110
112
|
end
|
data/lib/gzr/commands/folder.rb
CHANGED
@@ -66,6 +66,8 @@ module Gzr
|
|
66
66
|
desc: 'Display usage information'
|
67
67
|
method_option :plans, type: :boolean,
|
68
68
|
desc: 'Include scheduled plans'
|
69
|
+
method_option :trim, type: :boolean,
|
70
|
+
desc: 'Trim output to minimal set of fields for later import'
|
69
71
|
method_option :dir, type: :string, default: '.',
|
70
72
|
desc: 'Directory to store output tree'
|
71
73
|
method_option :tar, type: :string,
|
@@ -43,6 +43,7 @@ module Gzr
|
|
43
43
|
say_warning("options: #{@options.inspect}") if @options[:debug]
|
44
44
|
with_session do
|
45
45
|
data = cat_look(@look_id)
|
46
|
+
data = trim_look(data) if @options[:trim]
|
46
47
|
file_name = if @options[:dir]
|
47
48
|
@options[:simple_filename] ? "Look_#{data[:id]}.json" : "Look_#{data[:id]}_#{data[:title]}.json"
|
48
49
|
else
|
data/lib/gzr/commands/look.rb
CHANGED
@@ -84,6 +84,8 @@ module Gzr
|
|
84
84
|
desc: 'Include scheduled plans'
|
85
85
|
method_option :simple_filename, type: :boolean,
|
86
86
|
desc: 'Use simple filename for output (Look_<id>.json)'
|
87
|
+
method_option :trim, type: :boolean,
|
88
|
+
desc: 'Trim output to minimal set of fields for later import'
|
87
89
|
def cat(look_id)
|
88
90
|
if options[:help]
|
89
91
|
invoke :help, ['cat']
|
@@ -266,5 +266,72 @@ module Gzr
|
|
266
266
|
data[:scheduled_plans] = query_scheduled_plans_for_dashboard(@dashboard_id,"all") if @options[:plans]
|
267
267
|
data
|
268
268
|
end
|
269
|
+
|
270
|
+
def trim_dashboard(data)
|
271
|
+
trimmed = data.select do |k,v|
|
272
|
+
(keys_to_keep('update_dashboard') + [:id,:dashboard_elements,:dashboard_filters,:dashboard_layouts,:scheduled_plans]).include? k
|
273
|
+
end
|
274
|
+
|
275
|
+
trimmed[:dashboard_elements] = data[:dashboard_elements].map do |de|
|
276
|
+
new_de = de.select do |k,v|
|
277
|
+
(keys_to_keep('update_dashboard_element') + [:id,:look,:query,:merge_result]).include? k
|
278
|
+
end
|
279
|
+
if de[:look]
|
280
|
+
new_de[:look] = de[:look].select do |k,v|
|
281
|
+
(keys_to_keep('update_look') + [:id,:query]).include? k
|
282
|
+
end
|
283
|
+
if de[:look][:query]
|
284
|
+
new_de[:look][:query] = de[:look][:query].select do |k,v|
|
285
|
+
(keys_to_keep('create_query') + [:id]).include? k
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
if de[:query]
|
290
|
+
new_de[:query] = de[:query].select do |k,v|
|
291
|
+
(keys_to_keep('create_query') + [:id]).include? k
|
292
|
+
end
|
293
|
+
end
|
294
|
+
if de[:merge_result]
|
295
|
+
new_de[:merge_result] = de[:merge_result].select do |k,v|
|
296
|
+
(keys_to_keep('update_merge_query') + [:id]).include? k
|
297
|
+
end
|
298
|
+
new_de[:merge_result][:source_queries] = de[:merge_result][:source_queries].map do |sq|
|
299
|
+
sq.select do |k,v|
|
300
|
+
(keys_to_keep('create_query') + [:id]).include? k
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
new_de
|
305
|
+
end
|
306
|
+
|
307
|
+
trimmed[:dashboard_filters] = data[:dashboard_filters].map do |df|
|
308
|
+
new_df = df.select do |k,v|
|
309
|
+
keys_to_keep('update_dashboard_filter').include? k
|
310
|
+
end
|
311
|
+
new_df
|
312
|
+
end
|
313
|
+
|
314
|
+
trimmed[:dashboard_layouts] = data[:dashboard_layouts].map do |dl|
|
315
|
+
new_dl = dl.select do |k,v|
|
316
|
+
(keys_to_keep('update_dashboard_layout') + [:id]).include? k
|
317
|
+
end
|
318
|
+
if dl[:dashboard_layout_components]
|
319
|
+
new_dl[:dashboard_layout_components] = dl[:dashboard_layout_components].map do |dlc|
|
320
|
+
dlc.select do |k,v|
|
321
|
+
(keys_to_keep('update_dashboard_layout_component') + [:id]).include? k
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
new_dl
|
326
|
+
end
|
327
|
+
|
328
|
+
trimmed[:scheduled_plans] = data[:scheduled_plans].map do |sp|
|
329
|
+
sp.select do |k,v|
|
330
|
+
(keys_to_keep('create_scheduled_plan') + [:id]).include? k
|
331
|
+
end
|
332
|
+
end if data[:scheduled_plans]
|
333
|
+
|
334
|
+
trimmed
|
335
|
+
end
|
269
336
|
end
|
270
337
|
end
|
data/lib/gzr/modules/look.rb
CHANGED
@@ -198,8 +198,25 @@ module Gzr
|
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
201
|
-
data[:scheduled_plans] = query_scheduled_plans_for_look(@look_id,"all")
|
201
|
+
data[:scheduled_plans] = query_scheduled_plans_for_look(@look_id,"all").map { |e| e.to_attrs } if @options[:plans]
|
202
202
|
data
|
203
203
|
end
|
204
|
+
|
205
|
+
def trim_look(data)
|
206
|
+
trimmed = data.select do |k,v|
|
207
|
+
(keys_to_keep('update_look') + [:id,:query]).include? k
|
208
|
+
end
|
209
|
+
trimmed[:query] = data[:query].select do |k,v|
|
210
|
+
(keys_to_keep('create_query') + [:id]).include? k
|
211
|
+
end
|
212
|
+
|
213
|
+
trimmed[:scheduled_plans] = data[:scheduled_plans].map do |sp|
|
214
|
+
sp.select do |k,v|
|
215
|
+
(keys_to_keep('create_scheduled_plan') + [:id]).include? k
|
216
|
+
end
|
217
|
+
end if data[:scheduled_plans]
|
218
|
+
|
219
|
+
trimmed
|
220
|
+
end
|
204
221
|
end
|
205
222
|
end
|
data/lib/gzr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gazer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike DeAngelo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-reader
|