class RedashExporter::Queries

Constants

ENDPOINT

Attributes

api_key[RW]
queries[RW]
redash_url[RW]

Public Class Methods

new(redash_url, api_key, dest = " click to toggle source
# File lib/redash_exporter/queries.rb, line 18
def initialize(redash_url, api_key, dest = "#{__dir__}/../../dest")
  @redash_url = redash_url.gsub(%r{/$}, '')
  @api_key = api_key
  @dest = dest
  @queries = []
  @fetcher = Fetcher.new("#{@redash_url}#{ENDPOINT}", @api_key, page: 1, page_size: 250)
end

Public Instance Methods

export_all(force: false) click to toggle source
# File lib/redash_exporter/queries.rb, line 30
def export_all(force: false)
  dest_dir_path = File.expand_path(@dest)
  puts "Export SQL Files to #{dest_dir_path}"

  @queries.each do |query|
    query.export(dir: dest_dir_path, force: force)
  end

  puts "Done. Check out #{dest_dir_path}"
end
fetch() click to toggle source
# File lib/redash_exporter/queries.rb, line 26
def fetch
  @queries = @fetcher.fetch.map { |q| Query.new(q) }
end
reject!(*args, &block) click to toggle source
# File lib/redash_exporter/queries.rb, line 41
def reject!(*args, &block)
  @queries = reject(*args, &block)
end
select!(*args, &block) click to toggle source
# File lib/redash_exporter/queries.rb, line 45
def select!(*args, &block)
  @queries = select(*args, &block)
end