timescaledb 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/console +1 -1
- data/bin/tsdb +1 -1
- data/examples/all_in_one/all_in_one.rb +1 -1
- data/examples/ranking/config/initializers/timescale.rb +1 -2
- data/lib/timescaledb/migration_helpers.rb +19 -11
- data/lib/timescaledb/schema_dumper.rb +4 -1
- data/lib/timescaledb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1fef5df000abb1cc12f56397a1e18f452bf35c061260cf403809db25954451a
|
4
|
+
data.tar.gz: d00d7d94a33b52475a6e5415e7bab669be079f62b165abdb666764a907e34dc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b814e74e3403c5a0e12ed8d3e115aff9a44e67cf0eff46a94b396e5511c0ce7a316808b1cc563890e27892383e1d0c3358c97abb8f9f49577bc5c8b01fc3fe6
|
7
|
+
data.tar.gz: ac250f31153249745e7db4ce3b7d7bbacaa25934dd7915a5a4b2aaf02595b5332344b890d1ee7a759b193f75c554bf101b7e0c492104f539edf7fa094fba133e
|
data/Gemfile.lock
CHANGED
data/bin/console
CHANGED
data/bin/tsdb
CHANGED
@@ -72,26 +72,34 @@ module Timescaledb
|
|
72
72
|
# GROUP BY bucket
|
73
73
|
# SQL
|
74
74
|
#
|
75
|
-
def create_continuous_aggregate(
|
75
|
+
def create_continuous_aggregate(table_name, query, **options)
|
76
76
|
execute <<~SQL
|
77
|
-
CREATE MATERIALIZED VIEW #{
|
77
|
+
CREATE MATERIALIZED VIEW #{table_name}
|
78
78
|
WITH (timescaledb.continuous) AS
|
79
79
|
#{query.respond_to?(:to_sql) ? query.to_sql : query}
|
80
80
|
WITH #{"NO" unless options[:with_data]} DATA;
|
81
81
|
SQL
|
82
82
|
|
83
|
-
|
84
|
-
# TODO: assert valid keys
|
85
|
-
execute <<~SQL
|
86
|
-
SELECT add_continuous_aggregate_policy('#{name}',
|
87
|
-
start_offset => #{policy[:start_offset]},
|
88
|
-
end_offset => #{policy[:end_offset]},
|
89
|
-
schedule_interval => #{policy[:schedule_interval]});
|
90
|
-
SQL
|
91
|
-
end
|
83
|
+
create_continuous_aggregate_policy(table_name, options[:refresh_policies] || {})
|
92
84
|
end
|
93
85
|
alias_method :create_continuous_aggregates, :create_continuous_aggregate
|
94
86
|
|
87
|
+
def create_continuous_aggregate_policy(table_name, **options)
|
88
|
+
return if options.empty?
|
89
|
+
|
90
|
+
# TODO: assert valid keys
|
91
|
+
execute <<~SQL
|
92
|
+
SELECT add_continuous_aggregate_policy('#{table_name}',
|
93
|
+
start_offset => #{options[:start_offset]},
|
94
|
+
end_offset => #{options[:end_offset]},
|
95
|
+
schedule_interval => #{options[:schedule_interval]});
|
96
|
+
SQL
|
97
|
+
end
|
98
|
+
|
99
|
+
def remove_continuous_aggregate_policy(table_name)
|
100
|
+
execute "SELECT remove_continuous_aggregate_policy('#{table_name}')"
|
101
|
+
end
|
102
|
+
|
95
103
|
def create_retention_policy(table_name, interval:)
|
96
104
|
execute "SELECT add_retention_policy('#{table_name}', INTERVAL '#{interval}')"
|
97
105
|
end
|
@@ -10,13 +10,16 @@ module Timescaledb
|
|
10
10
|
|
11
11
|
def table(table_name, stream)
|
12
12
|
super(table_name, stream)
|
13
|
-
if
|
13
|
+
if Timescaledb::Hypertable.table_exists? &&
|
14
|
+
(hypertable = Timescaledb::Hypertable.find_by(hypertable_name: table_name))
|
14
15
|
timescale_hypertable(hypertable, stream)
|
15
16
|
timescale_retention_policy(hypertable, stream)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
20
|
def views(stream)
|
21
|
+
return unless Timescaledb::ContinuousAggregates.table_exists?
|
22
|
+
|
20
23
|
timescale_continuous_aggregates(stream) # Define these before any Scenic views that might use them
|
21
24
|
super if defined?(super)
|
22
25
|
end
|
data/lib/timescaledb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timescaledb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jônatas Davi Paganini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|