Module: Timescaledb::Rails::Model::ClassMethods
Overview
Constant Summary
Hyperfunctions::TIME_BUCKET_ALIAS
Instance Method Summary
collapse
#time_bucket
#find, #find_after, #find_at_time, #find_between
Instance Method Details
48
49
50
|
# File 'lib/timescaledb/rails/model.rb', line 48
def hypertable
Timescaledb::Rails::Hypertable.find_by(hypertable_where_options)
end
|
53
54
55
|
# File 'lib/timescaledb/rails/model.rb', line 53
def hypertable_chunks
Timescaledb::Rails::Chunk.where(hypertable_where_options)
end
|
63
64
65
|
# File 'lib/timescaledb/rails/model.rb', line 63
def hypertable_dimensions
Timescaledb::Rails::Dimension.where(hypertable_where_options)
end
|
58
59
60
|
# File 'lib/timescaledb/rails/model.rb', line 58
def hypertable_jobs
Timescaledb::Rails::Job.where(hypertable_where_options)
end
|
#hypertable_name ⇒ String
Returns only the name of the hypertable, table_name could include the schema path, we need to remove it.
31
32
33
|
# File 'lib/timescaledb/rails/model.rb', line 31
def hypertable_name
@hypertable_name ||= table_name.split('.').last
end
|
#hypertable_schema ⇒ String
Returns the schema where hypertable is stored.
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_name ⇒ 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
|