Skip to content

Commit cb52831

Browse files
author
Tomas Svarovsky
committed
Fixing replace in RDs
1 parent b7997c2 commit cb52831

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

lib/gooddata/models/metadata/report_definition.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,15 @@ def replace(what, for_what = nil)
316316

317317
content['grid']['metrics'] = metric_parts.map do |item|
318318
item.deep_dup.tap do |i|
319-
i['uri'].gsub!(uri_what, uri_for_what)
319+
i['uri'].gsub!("[#{uri_what}]", "[#{uri_for_what}]")
320320
end
321321
end
322322

323323
cols = content['grid']['columns'] || []
324324
content['grid']['columns'] = cols.map do |item|
325325
if item.is_a?(Hash)
326326
item.deep_dup.tap do |i|
327-
i['attribute']['uri'].gsub!(uri_what, uri_for_what)
327+
i['attribute']['uri'].gsub!("[#{uri_what}]", "[#{uri_for_what}]")
328328
end
329329
else
330330
item
@@ -335,7 +335,7 @@ def replace(what, for_what = nil)
335335
content['grid']['rows'] = rows.map do |item|
336336
if item.is_a?(Hash)
337337
item.deep_dup.tap do |i|
338-
i['attribute']['uri'].gsub!(uri_what, uri_for_what)
338+
i['attribute']['uri'].gsub!("[#{uri_what}]", "[#{uri_for_what}]")
339339
end
340340
else
341341
item
@@ -347,7 +347,7 @@ def replace(what, for_what = nil)
347347
if item.is_a?(Hash)
348348
item.deep_dup.tap do |i|
349349
if i['locator'][0].key?('attributeHeaderLocator')
350-
i['locator'][0]['attributeHeaderLocator']['uri'].gsub!(uri_what, uri_for_what)
350+
i['locator'][0]['attributeHeaderLocator']['uri'].gsub!("[#{uri_what}]", "[#{uri_for_what}]")
351351
end
352352
end
353353
else
@@ -362,8 +362,8 @@ def replace(what, for_what = nil)
362362
next unless i.key?('metricSort')
363363
next unless i['metricSort'].key?('locators')
364364
next unless i['metricSort']['locators'][0].key?('attributeLocator2')
365-
i['metricSort']['locators'][0]['attributeLocator2']['uri'].gsub!(uri_what, uri_for_what)
366-
i['metricSort']['locators'][0]['attributeLocator2']['element'].gsub!(uri_what, uri_for_what)
365+
i['metricSort']['locators'][0]['attributeLocator2']['uri'].gsub!("[#{uri_what}]", "[#{uri_for_what}]")
366+
i['metricSort']['locators'][0]['attributeLocator2']['element'].gsub!("[#{uri_what}]", "[#{uri_for_what}]")
367367
end
368368
else
369369
item
@@ -374,17 +374,16 @@ def replace(what, for_what = nil)
374374
content['chart']['buckets'] = content['chart']['buckets'].reduce({}) do |a, e|
375375
key = e[0]
376376
val = e[1]
377-
# binding.pry
378377
a[key] = val.map do |item|
379378
item.deep_dup.tap do |i|
380-
i['uri'].gsub!(uri_what, uri_for_what)
379+
i['uri'].gsub!("[#{uri_what}]", "[#{uri_for_what}]")
381380
end
382381
end
383382
a
384383
end
385384
end
386385

387-
content['filters'] = filters.map { |filter_expression| { 'expression' => filter_expression.gsub(uri_what, uri_for_what) } }
386+
content['filters'] = filters.map { |filter_expression| { 'expression' => filter_expression.gsub("[#{uri_what}]", "[#{uri_for_what}]") } }
388387
end
389388
self
390389
end

0 commit comments

Comments
 (0)