Method: GoodData::Project#execute_maql

Defined in:
lib/gooddata/models/project.rb

#execute_maql(maql, options = {}) ⇒ Hash

Executes MAQL expression and waits for it to be finished.

Parameters:

  • maql (String)

    MAQL expression

Returns:

  • (Hash)

    Result of executing MAQL

[View source]

1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
# File 'lib/gooddata/models/project.rb', line 1074

def execute_maql(maql, options = {})
  ldm_links = client.get(md[GoodData::Model::LDM_CTG])
  ldm_uri = Links.new(ldm_links)[GoodData::Model::LDM_MANAGE_CTG]
  response = client.post(ldm_uri, manage: { maql: maql })
  polling_uri = response['entries'].first['link']

  result = client.poll_on_response(polling_uri, options) do |body|
    body && body['wTaskStatus'] && body['wTaskStatus']['status'] == 'RUNNING'
  end
  if result['wTaskStatus']['status'] == 'ERROR'
    fail MaqlExecutionError.new("Executionof MAQL '#{maql}' failed in project '#{pid}'", result)
  end
  result
end