Module: Timescaledb::Rails::Model::ClassMethods

Defined in:
lib/timescaledb/rails/model.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#hypertableTimescaledb::Rails::Hypertable



39
40
41
# File 'lib/timescaledb/rails/model.rb', line 39

def hypertable
  Timescaledb::Rails::Hypertable.find_by(hypertable_where_options)
end

#hypertable_chunksActiveRecord::Relation<Timescaledb::Rails::Chunk>

Returns:



44
45
46
# File 'lib/timescaledb/rails/model.rb', line 44

def hypertable_chunks
  Timescaledb::Rails::Chunk.where(hypertable_where_options)
end

#hypertable_compression_settingsActiveRecord::Relation<Timescaledb::Rails::CompressionSetting>

Returns:



59
60
61
# File 'lib/timescaledb/rails/model.rb', line 59

def hypertable_compression_settings
  Timescaledb::Rails::CompressionSetting.where(hypertable_where_options)
end

#hypertable_dimensionsActiveRecord::Relation<Timescaledb::Rails::Dimension>

Returns:



54
55
56
# File 'lib/timescaledb/rails/model.rb', line 54

def hypertable_dimensions
  Timescaledb::Rails::Dimension.where(hypertable_where_options)
end

#hypertable_jobsActiveRecord::Relation<Timescaledb::Rails::Job>

Returns:



49
50
51
# File 'lib/timescaledb/rails/model.rb', line 49

def hypertable_jobs
  Timescaledb::Rails::Job.where(hypertable_where_options)
end

#hypertable_nameString

Returns only the name of the hypertable, table_name could include the schema path, we need to remove it.

Returns:

  • (String)


23
24
25
# File 'lib/timescaledb/rails/model.rb', line 23

def hypertable_name
  table_name.split('.').last
end

#hypertable_schemaString

Returns the schema where hypertable is stored.

Returns:

  • (String)


30
31
32
33
34
35
36
# File 'lib/timescaledb/rails/model.rb', line 30

def hypertable_schema
  if table_name.split('.').size > 1
    table_name.split('.')[0..-2].join('.')
  else
    PUBLIC_SCHEMA_NAME
  end
end