gooddata 0.6.13 → 0.6.14

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: cb9665af325baabe9f6f170e113ca64b2a0f1d52
4
- data.tar.gz: 851eae13fb6b6dedd5ebb4e27f18e5ef6ea78636
3
+ metadata.gz: 8b2cc95365699b104ccca0c4a8bcc150f7185cec
4
+ data.tar.gz: 713eb96fa8fe826ea998168fdcce76bc220f5ee2
5
5
  SHA512:
6
- metadata.gz: e846c86dff64caceda53415158c122204e76159be7a14357456e9ebb5f5074d3b693a0f25d208bdd61aedfe4a2ba6a20da699d908fec6b30bedd7a34fdfb8ff2
7
- data.tar.gz: 3559aa1d3e696ff1d1e9f686c505ef8042346d5ca867f1fc0fe8f9cb0332759c9a2a98b95174981b557299ee087613a8c32aeab040aedca1c9bef2a4024bb197
6
+ metadata.gz: 1b55029ce133fe1513da60dbfac57a56c4b76d3f6cd9bd5532505e9eeff07437c589e7114b7e116b22de505530a41dacbaacd81d678fe33287ac7aae304c30f4
7
+ data.tar.gz: 13635e9b44dbe5aeca95b86a42e7309d5c3d322cd43ad71196b88aae3dcc69c0178b170ac921513b67909d6081c35ebe52b7e4d5d43814290a239142ccd05748
@@ -1,5 +1,11 @@
1
1
  # GoodData Ruby SDK Changelog
2
2
 
3
+ ## 0.6.14
4
+
5
+ - Project update from blueprint does not fail when MAQL chunks are empty.
6
+ - You can call migrate_datasets with dry_run to obtain MAQL chunks.
7
+ - Fix of title generation in blueprint from wire.
8
+
3
9
  ## 0.6.13
4
10
 
5
11
  - Fixed TT problems
@@ -90,7 +90,7 @@ module GoodData
90
90
  d[:type] = :date_dimension
91
91
  # d[:urn] = :date_dimension
92
92
  d[:name] = stuff['dateDimension']['name']
93
- d[:title] = stuff['dateDimension']['title'] if stuff['dateDimension']['title'] != stuff['dateDimension']['title'].titleize
93
+ d[:title] = stuff['dateDimension']['title'] if stuff['dateDimension']['title'] != d[:name].titleize
94
94
  end
95
95
  end
96
96
 
@@ -29,7 +29,7 @@ module GoodData
29
29
  item[:title] || item[:name].titleize
30
30
  end
31
31
 
32
- def identifier_for(dataset, column = nil, column2 = nil)
32
+ def identifier_for(dataset, column = nil, column2 = nil) # rubocop:disable UnusedMethodArgument
33
33
  return "dataset.#{dataset[:name]}" if column.nil?
34
34
  column = DatasetBlueprint.find_column_by_name(dataset, column) if column.is_a?(String)
35
35
  case column[:type].to_sym
@@ -46,11 +46,15 @@ module GoodData
46
46
  when :primary_label
47
47
  "label.#{dataset[:name]}.#{column[:name]}"
48
48
  when :label
49
- "label.#{dataset[:name]}.#{column2[:name]}.#{column[:name]}"
49
+ "label.#{dataset[:name]}.#{column[:reference]}.#{column[:name]}"
50
50
  when :date_ref
51
51
  "#{dataset[:name]}.date.mdyy"
52
52
  when :dataset
53
53
  "dataset.#{dataset[:name]}"
54
+ when :date
55
+ 'DATE'
56
+ when :reference
57
+ 'REF'
54
58
  else
55
59
  fail "Unknown type #{column[:type].to_sym}"
56
60
  end
@@ -9,7 +9,8 @@ module GoodData
9
9
  module Model
10
10
  class ProjectCreator
11
11
  class << self
12
- def migrate(opts = { client: GoodData.connection, project: GoodData.project })
12
+ def migrate(opts = {})
13
+ opts = { client: GoodData.connection, project: GoodData.project }.merge(opts)
13
14
  client = opts[:client]
14
15
  fail ArgumentError, 'No :client specified' if client.nil?
15
16
 
@@ -25,27 +26,21 @@ module GoodData
25
26
 
26
27
  begin
27
28
  GoodData.with_project(project, opts) do |p|
28
- # migrate_date_dimensions(p, spec[:date_dimensions] || [])
29
- migrate_datasets(spec, :project => p, :client => client)
29
+ migrate_datasets(spec, opts.merge(project: p, client: client))
30
30
  load(p, spec)
31
31
  migrate_metrics(p, spec[:metrics] || [])
32
32
  migrate_reports(p, spec[:reports] || [])
33
33
  migrate_dashboards(p, spec[:dashboards] || [])
34
- migrate_users(p, spec[:users] || [])
35
34
  execute_tests(p, spec[:assert_tests] || [])
36
35
  p
37
36
  end
38
37
  end
39
38
  end
40
39
 
41
- def migrate_date_dimensions(project, spec)
42
- spec.each do |dd|
43
- Model.add_schema(DateDimension.new(dd), project)
44
- end
45
- end
46
-
47
- def migrate_datasets(spec, opts = { :client => GoodData.connection })
40
+ def migrate_datasets(spec, opts = {})
41
+ opts = { client: GoodData.connection }.merge(opts)
48
42
  client = opts[:client]
43
+ dry_run = opts[:dry_run]
49
44
  fail ArgumentError, 'No :client specified' if client.nil?
50
45
 
51
46
  p = opts[:project]
@@ -63,29 +58,29 @@ module GoodData
63
58
  link = result['asyncTask']['link']['poll']
64
59
  response = client.get(link, :process => false)
65
60
 
66
- # pp response
67
61
  while response.code != 200
68
62
  sleep 1
69
63
  GoodData::Rest::Client.retryable(:tries => 3) do
70
64
  sleep 1
71
65
  response = client.get(link, :process => false)
72
- # pp response
73
66
  end
74
67
  end
75
68
 
76
69
  response = client.get(link)
77
70
 
78
71
  chunks = pick_correct_chunks(response['projectModelDiff']['updateScripts'])
79
- chunks['updateScript']['maqlDdlChunks'].each do |chunk|
80
- result = project.execute_maql(chunk)
81
- fail 'Creating dataset failed' if result['wTaskStatus']['status'] == 'ERROR'
82
- end
83
-
84
- bp.datasets.zip(GoodData::Model::ToManifest.to_manifest(bp.to_hash)).each do |ds|
85
- dataset = ds[0]
86
- manifest = ds[1]
87
- GoodData::ProjectMetadata["manifest_#{dataset.name}", :client => client, :project => project] = manifest.to_json
72
+ if !chunks.nil? && !dry_run
73
+ chunks['updateScript']['maqlDdlChunks'].each do |chunk|
74
+ result = project.execute_maql(chunk)
75
+ fail 'Creating dataset failed' if result['wTaskStatus']['status'] == 'ERROR'
76
+ end
77
+ bp.datasets.zip(GoodData::Model::ToManifest.to_manifest(bp.to_hash)).each do |ds|
78
+ dataset = ds[0]
79
+ manifest = ds[1]
80
+ GoodData::ProjectMetadata["manifest_#{dataset.name}", :client => client, :project => project] = manifest.to_json
81
+ end
88
82
  end
83
+ chunks
89
84
  end
90
85
 
91
86
  def migrate_reports(project, spec)
@@ -106,13 +101,6 @@ module GoodData
106
101
  end
107
102
  end
108
103
 
109
- def migrate_users(_project, spec)
110
- spec.each do |user|
111
- puts "Would migrate user #{user}"
112
- # project.add_user(user)
113
- end
114
- end
115
-
116
104
  def load(project, spec)
117
105
  if spec.key?(:uploads) # rubocop:disable Style/GuardClause
118
106
  spec[:uploads].each do |load|
@@ -2,7 +2,7 @@
2
2
 
3
3
  # GoodData Module
4
4
  module GoodData
5
- VERSION = '0.6.13'
5
+ VERSION = '0.6.14'
6
6
 
7
7
  class << self
8
8
  # Version
@@ -20,6 +20,32 @@ describe "Full project implementation", :constraint => 'slow' do
20
20
  }.to raise_error(GoodData::ValidationError)
21
21
  end
22
22
 
23
+ it "should do nothing if the project is updated with the same blueprint" do
24
+ results = GoodData::Model::ProjectCreator.migrate_datasets(@spec, project: @project, client: @client, dry_run: true)
25
+ expect(results).to be_nil
26
+ end
27
+
28
+ it 'should try to rename a dataset back' do
29
+ dataset = @project.datasets('dataset.repos')
30
+ dataset.title = "Some title"
31
+ dataset.save
32
+
33
+ # Now the update of project using the original blueprint should offer update of the title. Nothing else.
34
+ results = GoodData::Model::ProjectCreator.migrate_datasets(@spec, project: @project, client: @client, dry_run: true)
35
+ expect(results['updateScript']['maqlDdl']).to eq "ALTER DATASET {dataset.repos} VISUAL(TITLE \"Repos\", DESCRIPTION \"\");\n"
36
+
37
+ # Update using a freshly gained blueprint should offer no changes.
38
+ new_blueprint = @project.blueprint
39
+ results = GoodData::Model::ProjectCreator.migrate_datasets(new_blueprint, project: @project, client: @client, dry_run: true)
40
+ expect(results).to be_nil
41
+
42
+ # When we change the model using the original blueprint. Basically change the title back.
43
+ results = GoodData::Model::ProjectCreator.migrate_datasets(@spec, project: @project, client: @client)
44
+ # It should offer no changes using the original blueprint
45
+ results = GoodData::Model::ProjectCreator.migrate_datasets(@spec, project: @project, client: @client, dry_run: true)
46
+ expect(results).to be_nil
47
+ end
48
+
23
49
  it "should contain datasets" do
24
50
  @project.blueprint.tap do |bp|
25
51
  expect(bp.datasets.count).to eq 3
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.13
4
+ version: 0.6.14
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: 2015-02-09 00:00:00.000000000 Z
14
+ date: 2015-02-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake