gooddata 0.6.35 → 0.6.36

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
  SHA1:
3
- metadata.gz: 8ed8d8970f4e3251134ddbe30ef6a78e4011863a
4
- data.tar.gz: 94374f72b58dad355ab82b6e5e71a576beca8d19
3
+ metadata.gz: 6a418eb31981fffaf7e3a4d2099ee45c13fe94d7
4
+ data.tar.gz: f99f2d29de0abe85b6aa852c1654a1116df55573
5
5
  SHA512:
6
- metadata.gz: 0c5f73feffd8973277e8e5146ffd3aaf6fb1a056d921e1599baaade6859e192cf223a638627562f159516d3b7b6ce6004893701b0a43304e2d9f7aa23ff983fb
7
- data.tar.gz: 3a9fb83e65f7f0d812ca668c00fae2085ff8873362e1518e9ec2d25c423ae0487f408f95e7940c1a32b1a58a9f6fce5f0eea31ae19187f8b1c01c26223c502c9
6
+ metadata.gz: 7c3a1ea8b743b34796d6dc6ac208cf0bdf6f2757ba0bf46ba41ef2b81c2170adf12334402129d776f3ce64ad3780765dde57395d50b6ca6b8a63a4a638767d73
7
+ data.tar.gz: 19d9d787859a139a208ad33f185365ecc0f7272847af0397ec54e71f895028466cf156ac33192d0e39ae8ef252ddbd829109d0ccf0375184260a91a8a1e22bec
@@ -0,0 +1,7 @@
1
+ class String
2
+ def to_b
3
+ return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
4
+ return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
5
+ raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
6
+ end
7
+ end
@@ -27,18 +27,23 @@ module GoodData
27
27
  messages
28
28
  end
29
29
 
30
- def transfer_everything(client, domain, migration_spec, filter_on_segment = [])
30
+ def transfer_everything(client, domain, migration_spec, filter_on_segment = [], opts = {})
31
31
  puts 'Ensuring Users - warning: works across whole domain not just provided segment(s)'
32
32
  ensure_users(domain, migration_spec, filter_on_segment)
33
33
 
34
34
  puts 'Migrating Blueprints'
35
35
 
36
+ bp_opts = {
37
+ update_preference: opts[:update_preference] || opts['update_preference'],
38
+ maql_replacements: opts[:maql_replacements] || opts['maql_replacements']
39
+ }
40
+
36
41
  domain.segments.peach do |segment|
37
42
  next if !filter_on_segment.empty? && !(filter_on_segment.include?(segment.id))
38
43
  bp = segment.master_project.blueprint
39
44
  segment.clients.each do |c|
40
45
  p = c.project
41
- p.update_from_blueprint(bp)
46
+ p.update_from_blueprint(bp, bp_opts)
42
47
  end
43
48
  end
44
49
 
@@ -59,17 +59,32 @@ module GoodData
59
59
 
60
60
  response = client.get(link)
61
61
 
62
- chunks = pick_correct_chunks(response['projectModelDiff']['updateScripts'], opts)
63
- if !chunks.nil? && !dry_run
64
- chunks['updateScript']['maqlDdlChunks'].each do |chunk|
65
- result = project.execute_maql(chunk)
66
- if result['wTaskStatus']['status'] == 'ERROR'
67
- puts JSON.pretty_generate(result)
68
- fail 'Creating dataset failed'
62
+ maqls = pick_correct_chunks(response['projectModelDiff']['updateScripts'], opts)
63
+ if !maqls.empty? && !dry_run
64
+ maqls.each_with_index do |maql, _idx|
65
+ begin
66
+ chunks = maql[:orig]['updateScript']['maqlDdlChunks']
67
+ chunks.each do |chunk|
68
+ # TODO: Hack the MAQL here
69
+ (opts[:maql_replacements] || opts['maql_replacements'] || {}).each do |k, v|
70
+ src = Regexp.new(k)
71
+ dest = v
72
+ chunk.gsub!(src, dest)
73
+ end
74
+
75
+ result = project.execute_maql(chunk)
76
+ if result['wTaskStatus']['status'] == 'ERROR'
77
+ puts JSON.pretty_generate(result)
78
+ fail 'Creating dataset failed'
79
+ end
80
+ end
81
+ return chunks
82
+ rescue => e
83
+ puts "Error occured when executing MAQL, project: \"#{project.title}\" reason: \"#{e.message}\", chunks: #{chunks.inspect}"
84
+ next
69
85
  end
70
86
  end
71
87
  end
72
- chunks
73
88
  end
74
89
 
75
90
  def migrate_reports(project, spec)
@@ -109,7 +124,8 @@ module GoodData
109
124
  end
110
125
 
111
126
  def pick_correct_chunks(chunks, opts = {})
112
- preference = opts[:preference] || {}
127
+ preference = opts[:update_preference]
128
+
113
129
  # first is cascadeDrops, second is preserveData
114
130
  rules = [
115
131
  { priority: 1, cascade_drops: false, preserve_data: true },
@@ -117,11 +133,25 @@ module GoodData
117
133
  { priority: 3, cascade_drops: true, preserve_data: true },
118
134
  { priority: 4, cascade_drops: true, preserve_data: false }
119
135
  ]
120
- stuff = chunks.select { |chunk| chunk['updateScript']['maqlDdlChunks'] }.map { |chunk| { cascade_drops: chunk['updateScript']['cascadeDrops'], preserve_data: chunk['updateScript']['preserveData'], maql: chunk['updateScript']['maqlDdlChunks'], orig: chunk } }
121
- results = GoodData::Helpers.join(rules, stuff, [:cascade_drops, :preserve_data], [:cascade_drops, :preserve_data], inner: true).sort_by { |l| l[:priority] }
122
136
 
123
- pick = results.find { |r| r.values_at(:cascade_drops, :preserve_data) == preference.values_at(:cascade_drops, :preserve_data) } || results.first
124
- pick[:orig] if pick
137
+ stuff = chunks.select do |chunk|
138
+ chunk['updateScript']['maqlDdlChunks']
139
+ end
140
+
141
+ stuff = stuff.map do |chunk|
142
+ { cascade_drops: chunk['updateScript']['cascadeDrops'], preserve_data: chunk['updateScript']['preserveData'], maql: chunk['updateScript']['maqlDdlChunks'], orig: chunk }
143
+ end
144
+
145
+ results = GoodData::Helpers.join(rules, stuff, [:cascade_drops, :preserve_data], [:cascade_drops, :preserve_data], inner: true).sort_by { |l| l[:priority] } || []
146
+
147
+ (preference || {}).each do |k, v|
148
+ results = results.find_all do |result|
149
+ sym = k.to_sym
150
+ !result.has_key?(sym) || result[sym] == v
151
+ end
152
+ end
153
+
154
+ preference ? results : [results.first]
125
155
  end
126
156
  end
127
157
  end
@@ -6,7 +6,7 @@
6
6
 
7
7
  # GoodData Module
8
8
  module GoodData
9
- VERSION = '0.6.35'
9
+ VERSION = '0.6.36'
10
10
 
11
11
  class << self
12
12
  # Version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.35
4
+ version: 0.6.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kolesnikov
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-09-27 00:00:00.000000000 Z
14
+ date: 2016-09-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -700,6 +700,7 @@ files:
700
700
  - lib/gooddata/extensions/nil.rb
701
701
  - lib/gooddata/extensions/numeric.rb
702
702
  - lib/gooddata/extensions/object.rb
703
+ - lib/gooddata/extensions/string.rb
703
704
  - lib/gooddata/extensions/symbol.rb
704
705
  - lib/gooddata/extensions/true.rb
705
706
  - lib/gooddata/extract.rb