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

Includes:
FinderMethods, Hyperfunctions
Defined in:
lib/timescaledb/rails/model.rb

Overview

:nodoc:

Constant Summary

Constants included from Hyperfunctions

Hyperfunctions::TIME_BUCKET_ALIAS

Instance Method Summary collapse

Methods included from Hyperfunctions

#time_bucket

Methods included from FinderMethods

#find, #find_after, #find_at_time, #find_between

Instance Method Details

#hypertableTimescaledb::Rails::Hypertable



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

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

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

Returns:



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

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

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

Returns:



68
69
70
# File 'lib/timescaledb/rails/model.rb', line 68

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

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

Returns:



63
64
65
# File 'lib/timescaledb/rails/model.rb', line 63

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

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

Returns:



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

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)


31
32
33
# File 'lib/timescaledb/rails/model.rb', line 31

def hypertable_name
  @hypertable_name ||= table_name.split('.').last
end

#hypertable_schemaString

Returns the schema where hypertable is stored.

Returns:

  • (String)


38
39
40
41
42
43
44
45
# File 'lib/timescaledb/rails/model.rb', line 38

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

#hypertable_time_column_nameString

Returns:

  • (String)


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

def hypertable_time_column_name
  @hypertable_time_column_name ||= hypertable&.time_column_name
end