Sha256: 2bd8e9e1247b931cb0d164d26b735fd630ded82f5e77f14c420b3a973d0589f1

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module GoodData
  class Report < GoodData::MdObject 

    class << self
      def [](id)
        if id == :all
          GoodData.get(GoodData.project.md['query'] + '/reports/')['query']['entries']
        else 
          super
        end
      end
    end

    def results
      content["results"]
    end

    def get_latest_report_definition_uri
      report_result = get_latest_report_result
      report_result.content["reportDefinition"]
    end

    def get_latest_report_definition
      GoodData::MdObject[get_latest_report_definition_uri]
    end

    def get_latest_report_result_uri
      results.last
    end

    def get_latest_report_result
      GoodData::MdObject[get_latest_report_result_uri]
    end

    def execute
      # puts "Executing report #{uri}"
      result = GoodData.post '/gdc/xtab2/executor3', {"report_req" => {"report" => uri}}
      
      dataResultUri = result["reportResult2"]["content"]["dataResult"]
      result = GoodData.get dataResultUri
      return EmptyResult.new([]) if result.nil?

      while result["taskState"] && result["taskState"]["status"] == "WAIT" do
        sleep 10
        result = GoodData.get dataResultUri
      end
      ReportDataResult.new(GoodData.get dataResultUri)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gooddata-0.5.6 lib/gooddata/models/report.rb