Sha256: b40c36e8f01853d04e035acc79130c8cd7cf5785679f3245922544385fd56cd1

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

#!/usr/bin/env ruby
require "bundler/setup"
require "timescale"
require "pry"

ActiveRecord::Base.establish_connection(ARGV[0])

Timescale::Hypertable.find_each do |hypertable|
  class_name = hypertable.hypertable_name.singularize.camelize
  model = Class.new(ActiveRecord::Base) do
    self.table_name = hypertable.hypertable_name
    acts_as_hypertable
  end
  Timescale.const_set(class_name, model)
end

Timescale::ContinuousAggregates.find_each do |cagg|
  class_name = cagg.view_name.singularize.camelize
  model = Class.new(ActiveRecord::Base) do
    self.table_name = cagg.view_name
    acts_as_hypertable
  end
  Timescale.const_set(class_name, model)
end

def show(obj)
  Pry::ColorPrinter.pp(obj)
end

if ARGV.index("--stats")
  scope = Timescale::Hypertable.all

  if (only = ARGV.index("--only"))
    only_hypertables = ARGV[only+1].split(",")
    scope = scope.where({hypertable_name: only_hypertables})
  end

  if (except = ARGV.index("--except"))
    except_hypertables = ARGV[except+1].split(",")
    scope = scope.where.not(hypertable_name: except_hypertables)
  end

  show(Timescale.stats(scope))
end

if ARGV.index("--console")
  Pry.start(Timescale)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
timescaledb-0.1.5 bin/tsdb
timescaledb-0.1.4 bin/tsdb
timescaledb-0.1.3 bin/tsdb