timescaledb 0.2.6 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tsdb +30 -29
  3. data/lib/timescaledb/acts_as_hypertable/core.rb +1 -1
  4. data/lib/timescaledb/acts_as_hypertable.rb +5 -2
  5. data/lib/timescaledb/connection.rb +43 -0
  6. data/lib/timescaledb/connection_handling.rb +16 -0
  7. data/lib/timescaledb/database/chunk_statements.rb +21 -0
  8. data/lib/timescaledb/database/hypertable_statements.rb +37 -0
  9. data/lib/timescaledb/database/quoting.rb +12 -0
  10. data/lib/timescaledb/database/schema_statements.rb +246 -0
  11. data/lib/timescaledb/database/types.rb +20 -0
  12. data/lib/timescaledb/database.rb +15 -0
  13. data/lib/timescaledb/migration_helpers.rb +36 -8
  14. data/lib/timescaledb/schema_dumper.rb +40 -12
  15. data/lib/timescaledb/stats/chunks.rb +41 -0
  16. data/lib/timescaledb/stats/continuous_aggregates.rb +24 -0
  17. data/lib/timescaledb/stats/hypertables.rb +102 -0
  18. data/lib/timescaledb/stats/job_stats.rb +29 -0
  19. data/lib/timescaledb/stats.rb +22 -0
  20. data/lib/timescaledb/toolkit/time_vector.rb +21 -17
  21. data/lib/timescaledb/version.rb +1 -1
  22. data/lib/timescaledb.rb +3 -0
  23. metadata +15 -95
  24. data/.github/workflows/ci.yml +0 -72
  25. data/.gitignore +0 -12
  26. data/.rspec +0 -3
  27. data/.ruby-version +0 -1
  28. data/.tool-versions +0 -1
  29. data/.travis.yml +0 -9
  30. data/CODE_OF_CONDUCT.md +0 -74
  31. data/Fastfile +0 -17
  32. data/Gemfile +0 -8
  33. data/Gemfile.lock +0 -75
  34. data/Gemfile.scenic +0 -7
  35. data/Gemfile.scenic.lock +0 -119
  36. data/README.md +0 -490
  37. data/Rakefile +0 -21
  38. data/bin/console +0 -28
  39. data/bin/setup +0 -13
  40. data/docs/command_line.md +0 -178
  41. data/docs/img/lttb_example.png +0 -0
  42. data/docs/img/lttb_sql_vs_ruby.gif +0 -0
  43. data/docs/img/lttb_zoom.gif +0 -0
  44. data/docs/index.md +0 -72
  45. data/docs/migrations.md +0 -76
  46. data/docs/models.md +0 -78
  47. data/docs/toolkit.md +0 -507
  48. data/docs/toolkit_lttb_tutorial.md +0 -557
  49. data/docs/toolkit_lttb_zoom.md +0 -357
  50. data/docs/toolkit_ohlc.md +0 -315
  51. data/docs/videos.md +0 -16
  52. data/examples/all_in_one/all_in_one.rb +0 -94
  53. data/examples/all_in_one/benchmark_comparison.rb +0 -108
  54. data/examples/all_in_one/caggs.rb +0 -93
  55. data/examples/all_in_one/query_data.rb +0 -78
  56. data/examples/ranking/.gitattributes +0 -7
  57. data/examples/ranking/.gitignore +0 -29
  58. data/examples/ranking/.ruby-version +0 -1
  59. data/examples/ranking/Gemfile +0 -33
  60. data/examples/ranking/Gemfile.lock +0 -189
  61. data/examples/ranking/README.md +0 -166
  62. data/examples/ranking/Rakefile +0 -6
  63. data/examples/ranking/app/controllers/application_controller.rb +0 -2
  64. data/examples/ranking/app/controllers/concerns/.keep +0 -0
  65. data/examples/ranking/app/jobs/application_job.rb +0 -7
  66. data/examples/ranking/app/models/application_record.rb +0 -3
  67. data/examples/ranking/app/models/concerns/.keep +0 -0
  68. data/examples/ranking/app/models/game.rb +0 -2
  69. data/examples/ranking/app/models/play.rb +0 -7
  70. data/examples/ranking/bin/bundle +0 -114
  71. data/examples/ranking/bin/rails +0 -4
  72. data/examples/ranking/bin/rake +0 -4
  73. data/examples/ranking/bin/setup +0 -33
  74. data/examples/ranking/config/application.rb +0 -39
  75. data/examples/ranking/config/boot.rb +0 -4
  76. data/examples/ranking/config/credentials.yml.enc +0 -1
  77. data/examples/ranking/config/database.yml +0 -86
  78. data/examples/ranking/config/environment.rb +0 -5
  79. data/examples/ranking/config/environments/development.rb +0 -60
  80. data/examples/ranking/config/environments/production.rb +0 -75
  81. data/examples/ranking/config/environments/test.rb +0 -53
  82. data/examples/ranking/config/initializers/cors.rb +0 -16
  83. data/examples/ranking/config/initializers/filter_parameter_logging.rb +0 -8
  84. data/examples/ranking/config/initializers/inflections.rb +0 -16
  85. data/examples/ranking/config/initializers/timescale.rb +0 -2
  86. data/examples/ranking/config/locales/en.yml +0 -33
  87. data/examples/ranking/config/puma.rb +0 -43
  88. data/examples/ranking/config/routes.rb +0 -6
  89. data/examples/ranking/config/storage.yml +0 -34
  90. data/examples/ranking/config.ru +0 -6
  91. data/examples/ranking/db/migrate/20220209120747_create_games.rb +0 -10
  92. data/examples/ranking/db/migrate/20220209120910_create_plays.rb +0 -19
  93. data/examples/ranking/db/migrate/20220209143347_create_score_per_hours.rb +0 -5
  94. data/examples/ranking/db/schema.rb +0 -47
  95. data/examples/ranking/db/seeds.rb +0 -7
  96. data/examples/ranking/db/views/score_per_hours_v01.sql +0 -7
  97. data/examples/ranking/lib/tasks/.keep +0 -0
  98. data/examples/ranking/log/.keep +0 -0
  99. data/examples/ranking/public/robots.txt +0 -1
  100. data/examples/ranking/storage/.keep +0 -0
  101. data/examples/ranking/tmp/.keep +0 -0
  102. data/examples/ranking/tmp/pids/.keep +0 -0
  103. data/examples/ranking/tmp/storage/.keep +0 -0
  104. data/examples/ranking/vendor/.keep +0 -0
  105. data/examples/toolkit-demo/compare_volatility.rb +0 -104
  106. data/examples/toolkit-demo/lttb/README.md +0 -15
  107. data/examples/toolkit-demo/lttb/lttb.rb +0 -92
  108. data/examples/toolkit-demo/lttb/lttb_sinatra.rb +0 -139
  109. data/examples/toolkit-demo/lttb/lttb_test.rb +0 -21
  110. data/examples/toolkit-demo/lttb/views/index.erb +0 -27
  111. data/examples/toolkit-demo/lttb-zoom/README.md +0 -13
  112. data/examples/toolkit-demo/lttb-zoom/lttb_zoomable.rb +0 -90
  113. data/examples/toolkit-demo/lttb-zoom/views/index.erb +0 -33
  114. data/examples/toolkit-demo/ohlc.rb +0 -175
  115. data/mkdocs.yml +0 -34
  116. data/timescaledb.gemspec +0 -40
@@ -2,10 +2,14 @@ require 'active_record/connection_adapters/postgresql_adapter'
2
2
  require 'active_support/core_ext/string/indent'
3
3
 
4
4
  module Timescaledb
5
+ # Schema dumper overrides default schema dumper to include:
6
+ # * hypertables
7
+ # * retention policies
8
+ # * continuous aggregates
9
+ # * compression settings
5
10
  module SchemaDumper
6
11
  def tables(stream)
7
12
  super # This will call #table for each table in the database
8
-
9
13
  return unless Timescaledb::Hypertable.table_exists?
10
14
 
11
15
  timescale_hypertables(stream)
@@ -13,6 +17,29 @@ module Timescaledb
13
17
  timescale_continuous_aggregates(stream) # Define these before any Scenic views that might use them
14
18
  end
15
19
 
20
+ # Ignores Timescale related schemas when dumping the schema
21
+ IGNORE_SCHEMAS = %w[
22
+ _timescaledb_cache
23
+ _timescaledb_config
24
+ _timescaledb_catalog
25
+ _timescaledb_debug
26
+ _timescaledb_functions
27
+ _timescaledb_internal
28
+ timescaledb_experimental
29
+ timescaledb_information
30
+ toolkit_experimental
31
+ ]
32
+
33
+ def schemas(stream)
34
+ schema_names = @connection.schema_names - ["public", *IGNORE_SCHEMAS]
35
+ if schema_names.any?
36
+ schema_names.sort.each do |name|
37
+ stream.puts " create_schema #{name.inspect}"
38
+ end
39
+ stream.puts
40
+ end
41
+ end
42
+
16
43
  def timescale_hypertables(stream)
17
44
  sorted_hypertables.each do |hypertable|
18
45
  timescale_hypertable(hypertable, stream)
@@ -112,19 +139,20 @@ module Timescaledb
112
139
  def timescale_continuous_aggregates(stream)
113
140
  return unless Timescaledb::ContinuousAggregates.table_exists?
114
141
 
115
- Timescaledb::ContinuousAggregates.all.each do |aggregate|
116
- opts = if (refresh_policy = aggregate.jobs.refresh_continuous_aggregate.first)
117
- interval = timescale_interval(refresh_policy.schedule_interval)
118
- end_offset = timescale_interval(refresh_policy.config["end_offset"])
119
- start_offset = timescale_interval(refresh_policy.config["start_offset"])
120
- %Q[, refresh_policies: { start_offset: "#{start_offset}", end_offset: "#{end_offset}", schedule_interval: "#{interval}"}]
121
- else
122
- ""
123
- end
142
+ Timescaledb::ContinuousAggregates.all.find_each do |aggregate|
143
+ refresh_policies_opts = if (refresh_policy = aggregate.jobs.refresh_continuous_aggregate.first)
144
+ interval = timescale_interval(refresh_policy.schedule_interval)
145
+ end_offset = timescale_interval(refresh_policy.config["end_offset"])
146
+ start_offset = timescale_interval(refresh_policy.config["start_offset"])
147
+ %(refresh_policies: { start_offset: "#{start_offset}", end_offset: "#{end_offset}", schedule_interval: "#{interval}"})
148
+ else
149
+ ""
150
+ end
124
151
 
152
+ with_clause_opts = "materialized_only: #{aggregate[:materialized_only]}, finalized: #{aggregate[:finalized]}"
125
153
  stream.puts <<~AGG.indent(2)
126
- create_continuous_aggregate("#{aggregate.view_name}", <<-SQL#{opts})
127
- #{aggregate.view_definition.strip.gsub(/;$/, "")}
154
+ create_continuous_aggregate("#{aggregate.view_name}", <<-SQL, #{refresh_policies_opts}, #{with_clause_opts})
155
+ #{aggregate.view_definition.strip.gsub(/;$/, '')}
128
156
  SQL
129
157
  AGG
130
158
  stream.puts
@@ -0,0 +1,41 @@
1
+ module Timescaledb
2
+ class Stats
3
+ class Chunks
4
+ # @param [Array<String>] hypertables The list of hypertable names.
5
+ # @param [Timescaledb:Connection] connection The PG connection.
6
+ def initialize(hypertables = [], connection = Timescaledb.connection)
7
+ @connection = connection
8
+ @hypertables = hypertables
9
+ end
10
+
11
+ delegate :query_count, to: :@connection
12
+
13
+ # @return [Hash] The chunks stats
14
+ def to_h
15
+ { total: total, compressed: compressed, uncompressed: uncompressed }
16
+ end
17
+
18
+ private
19
+
20
+ def total
21
+ query_count(base_query, [@hypertables])
22
+ end
23
+
24
+ def compressed
25
+ compressed_query = [base_query, 'is_compressed'].join(' AND ')
26
+
27
+ query_count(compressed_query, [@hypertables])
28
+ end
29
+
30
+ def uncompressed
31
+ uncompressed_query = [base_query, 'NOT is_compressed'].join(' AND ')
32
+
33
+ query_count(uncompressed_query, [@hypertables])
34
+ end
35
+
36
+ def base_query
37
+ "SELECT COUNT(1) FROM timescaledb_information.chunks WHERE hypertable_name IN ($1)"
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,24 @@
1
+
2
+ module Timescaledb
3
+ class Stats
4
+ class ContinuousAggregates
5
+ # @param [Timescaledb:Connection] connection The PG connection.
6
+ def initialize(connection = Timescaledb.connection)
7
+ @connection = connection
8
+ end
9
+
10
+ delegate :query_count, to: :@connection
11
+
12
+ # @return [Hash] The continuous_aggregates stats
13
+ def to_h
14
+ { total: total }
15
+ end
16
+
17
+ private
18
+
19
+ def total
20
+ query_count('SELECT COUNT(1) FROM timescaledb_information.continuous_aggregates')
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,102 @@
1
+ require_relative './chunks'
2
+
3
+ module Timescaledb
4
+ class Stats
5
+ class Hypertables
6
+ # @param [Timescaledb:Connection] connection The PG connection.
7
+ # @param [Array<String>] hypertables The list of hypertable names.
8
+ def initialize(hypertables = [], connection = Timescaledb.connection)
9
+ @connection = connection
10
+ @hypertables = hypertables.map(&method('hypertable_name_with_schema'))
11
+ end
12
+
13
+ delegate :query, :query_first, :query_count, to: :@connection
14
+
15
+ # @return [Hash] The hypertables stats
16
+ def to_h
17
+ {
18
+ count: @hypertables.count,
19
+ uncompressed_count: uncompressed_count,
20
+ approximate_row_count: approximate_row_count,
21
+ chunks: Timescaledb::Stats::Chunks.new(@hypertables).to_h,
22
+ size: size
23
+ }
24
+ end
25
+
26
+ private
27
+
28
+ def uncompressed_count
29
+ @hypertables.count do |hypertable|
30
+ query("SELECT * from hypertable_compression_stats('#{hypertable}')").empty?
31
+ end
32
+ end
33
+
34
+ def approximate_row_count
35
+ @hypertables.each_with_object(Hash.new) do |hypertable, summary|
36
+ row_count = query_first("SELECT * FROM approximate_row_count('#{hypertable}')").approximate_row_count.to_i
37
+
38
+ summary[hypertable] = row_count
39
+ end
40
+ end
41
+
42
+ def size
43
+ sum = -> (method_name) { (@hypertables.map(&method(method_name)).inject(:+) || 0) }
44
+
45
+ {
46
+ uncompressed: humanize_bytes(sum[:before_total_bytes]),
47
+ compressed: humanize_bytes(sum[:after_total_bytes])
48
+ }
49
+ end
50
+
51
+ def before_total_bytes(hypertable)
52
+ (compression_stats[hypertable]&.before_compression_total_bytes || detailed_size[hypertable]).to_i
53
+ end
54
+
55
+ def after_total_bytes(hypertable)
56
+ (compression_stats[hypertable]&.after_compression_total_bytes || 0).to_i
57
+ end
58
+
59
+ def compression_stats
60
+ @compression_stats ||=
61
+ @hypertables.each_with_object(Hash.new) do |hypertable, stats|
62
+ stats[hypertable] = query_first(compression_stats_query, [hypertable])
63
+ stats
64
+ end
65
+ end
66
+
67
+ def compression_stats_query
68
+ 'SELECT * FROM hypertable_compression_stats($1)'
69
+ end
70
+
71
+ def detailed_size
72
+ @detailed_size ||=
73
+ @hypertables.each_with_object(Hash.new) do |hypertable, size|
74
+ size[hypertable] = query_first(detailed_size_query, [hypertable]).total_bytes
75
+ size
76
+ end
77
+ end
78
+
79
+ def detailed_size_query
80
+ 'SELECT * FROM hypertable_detailed_size($1)'
81
+ end
82
+
83
+ def hypertable_name_with_schema(hypertable)
84
+ [hypertable.hypertable_schema, hypertable.hypertable_name].compact.join('.')
85
+ end
86
+
87
+ def humanize_bytes(bytes)
88
+ units = %w(B KiB MiB GiB TiB PiB EiB)
89
+
90
+ return '0 B' if bytes == 0
91
+
92
+ exp = (Math.log2(bytes) / 10).floor
93
+ max_exp = units.size - 1
94
+ exp = max_exp if exp > max_exp
95
+
96
+ value = (bytes.to_f / (1 << (exp * 10))).round(1)
97
+
98
+ "#{value} #{units[exp]}"
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,29 @@
1
+
2
+ module Timescaledb
3
+ class Stats
4
+ class JobStats
5
+ # @param [Timescaledb:Connection] connection The PG connection.
6
+ def initialize(connection = Timescaledb.connection)
7
+ @connection = connection
8
+ end
9
+
10
+ delegate :query_first, to: :@connection
11
+
12
+ # @return [Hash] The job_stats stats
13
+ def to_h
14
+ query_first(job_stats_query).to_h.transform_values(&:to_i)
15
+ end
16
+
17
+ private
18
+
19
+ def job_stats_query
20
+ <<-SQL
21
+ SELECT SUM(total_successes)::INT AS success,
22
+ SUM(total_runs)::INT AS runs,
23
+ SUM(total_failures)::INT AS failures
24
+ FROM timescaledb_information.job_stats
25
+ SQL
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ require_relative './stats/continuous_aggregates'
2
+ require_relative './stats/hypertables'
3
+ require_relative './stats/job_stats'
4
+
5
+ module Timescaledb
6
+ class Stats
7
+ # @param [Array<OpenStruct>] hypertables The list of hypertables.
8
+ # @param [Timescaledb:Connection] connection The PG connection.
9
+ def initialize(hypertables = [], connection = Timescaledb.connection)
10
+ @hypertables = hypertables
11
+ @connection = connection
12
+ end
13
+
14
+ def to_h
15
+ {
16
+ hypertables: Hypertables.new(@hypertables).to_h,
17
+ continuous_aggregates: ContinuousAggregates.new.to_h,
18
+ jobs_stats: JobStats.new.to_h
19
+ }
20
+ end
21
+ end
22
+ end
@@ -42,7 +42,7 @@ module Timescaledb
42
42
  SELECT #{"x.#{segment_by}," if segment_by}
43
43
  (lttb( x.#{time_column}, x.#{value_column}, #{threshold}) -> unnest()).*
44
44
  FROM x
45
- #{"GROUP BY device_id" if segment_by}
45
+ #{"GROUP BY #{segment_by}" if segment_by}
46
46
  SQL
47
47
  downsampled = unscoped
48
48
  .select(*segment_by, "time as #{time_column}, value as #{value_column}")
@@ -59,35 +59,39 @@ module Timescaledb
59
59
  end
60
60
 
61
61
 
62
- scope :_ohlc, -> (timeframe: '1h',
62
+ scope :_candlestick, -> (timeframe: '1h',
63
63
  segment_by: segment_by_column,
64
64
  time: time_column,
65
+ volume: 'volume',
65
66
  value: value_column) do
66
67
 
67
- select( "time_bucket('#{timeframe}', #{time}) as #{time}",
68
- *segment_by,
69
- "toolkit_experimental.ohlc(#{time}, #{value})")
68
+ select( %|time_bucket('#{timeframe}', "#{time}")|,
69
+ *segment_by,
70
+ "candlestick_agg(#{time}, #{value}, #{volume}) as candlestick")
70
71
  .order(1)
71
72
  .group(*(segment_by ? [1,2] : 1))
72
73
  end
73
74
 
74
- scope :ohlc, -> (timeframe: '1h',
75
+ scope :candlestick, -> (timeframe: '1h',
75
76
  segment_by: segment_by_column,
76
77
  time: time_column,
78
+ volume: 'volume',
77
79
  value: value_column) do
78
80
 
79
- raw = _ohlc(timeframe: timeframe, segment_by: segment_by, time: time, value: value)
81
+ raw = _candlestick(timeframe: timeframe, segment_by: segment_by, time: time, value: value, volume: volume)
80
82
  unscoped
81
- .from("(#{raw.to_sql}) AS ohlc")
82
- .select(*segment_by, time,
83
- "toolkit_experimental.open(ohlc),
84
- toolkit_experimental.high(ohlc),
85
- toolkit_experimental.low(ohlc),
86
- toolkit_experimental.close(ohlc),
87
- toolkit_experimental.open_time(ohlc),
88
- toolkit_experimental.high_time(ohlc),
89
- toolkit_experimental.low_time(ohlc),
90
- toolkit_experimental.close_time(ohlc)")
83
+ .from("(#{raw.to_sql}) AS candlestick")
84
+ .select("time_bucket",*segment_by,
85
+ "open(candlestick),
86
+ high(candlestick),
87
+ low(candlestick),
88
+ close(candlestick),
89
+ open_time(candlestick),
90
+ high_time(candlestick),
91
+ low_time(candlestick),
92
+ close_time(candlestick),
93
+ volume(candlestick),
94
+ vwap(candlestick)")
91
95
  end
92
96
  end
93
97
  end
@@ -1,3 +1,3 @@
1
1
  module Timescaledb
2
- VERSION = '0.2.6'
2
+ VERSION = '0.2.8'
3
3
  end
data/lib/timescaledb.rb CHANGED
@@ -3,15 +3,18 @@ require 'active_record'
3
3
  require_relative 'timescaledb/application_record'
4
4
  require_relative 'timescaledb/acts_as_hypertable'
5
5
  require_relative 'timescaledb/acts_as_hypertable/core'
6
+ require_relative 'timescaledb/connection'
6
7
  require_relative 'timescaledb/toolkit'
7
8
  require_relative 'timescaledb/chunk'
8
9
  require_relative 'timescaledb/compression_settings'
10
+ require_relative 'timescaledb/connection_handling'
9
11
  require_relative 'timescaledb/continuous_aggregates'
10
12
  require_relative 'timescaledb/dimensions'
11
13
  require_relative 'timescaledb/hypertable'
12
14
  require_relative 'timescaledb/job'
13
15
  require_relative 'timescaledb/job_stats'
14
16
  require_relative 'timescaledb/schema_dumper'
17
+ require_relative 'timescaledb/stats'
15
18
  require_relative 'timescaledb/stats_report'
16
19
  require_relative 'timescaledb/migration_helpers'
17
20
  require_relative 'timescaledb/version'
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.6
4
+ version: 0.2.8
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: 2023-02-03 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -144,99 +144,8 @@ executables:
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
- - ".github/workflows/ci.yml"
148
- - ".gitignore"
149
- - ".rspec"
150
- - ".ruby-version"
151
- - ".tool-versions"
152
- - ".travis.yml"
153
- - CODE_OF_CONDUCT.md
154
- - Fastfile
155
- - Gemfile
156
- - Gemfile.lock
157
- - Gemfile.scenic
158
- - Gemfile.scenic.lock
159
147
  - LICENSE.txt
160
- - README.md
161
- - Rakefile
162
- - bin/console
163
- - bin/setup
164
148
  - bin/tsdb
165
- - docs/command_line.md
166
- - docs/img/lttb_example.png
167
- - docs/img/lttb_sql_vs_ruby.gif
168
- - docs/img/lttb_zoom.gif
169
- - docs/index.md
170
- - docs/migrations.md
171
- - docs/models.md
172
- - docs/toolkit.md
173
- - docs/toolkit_lttb_tutorial.md
174
- - docs/toolkit_lttb_zoom.md
175
- - docs/toolkit_ohlc.md
176
- - docs/videos.md
177
- - examples/all_in_one/all_in_one.rb
178
- - examples/all_in_one/benchmark_comparison.rb
179
- - examples/all_in_one/caggs.rb
180
- - examples/all_in_one/query_data.rb
181
- - examples/ranking/.gitattributes
182
- - examples/ranking/.gitignore
183
- - examples/ranking/.ruby-version
184
- - examples/ranking/Gemfile
185
- - examples/ranking/Gemfile.lock
186
- - examples/ranking/README.md
187
- - examples/ranking/Rakefile
188
- - examples/ranking/app/controllers/application_controller.rb
189
- - examples/ranking/app/controllers/concerns/.keep
190
- - examples/ranking/app/jobs/application_job.rb
191
- - examples/ranking/app/models/application_record.rb
192
- - examples/ranking/app/models/concerns/.keep
193
- - examples/ranking/app/models/game.rb
194
- - examples/ranking/app/models/play.rb
195
- - examples/ranking/bin/bundle
196
- - examples/ranking/bin/rails
197
- - examples/ranking/bin/rake
198
- - examples/ranking/bin/setup
199
- - examples/ranking/config.ru
200
- - examples/ranking/config/application.rb
201
- - examples/ranking/config/boot.rb
202
- - examples/ranking/config/credentials.yml.enc
203
- - examples/ranking/config/database.yml
204
- - examples/ranking/config/environment.rb
205
- - examples/ranking/config/environments/development.rb
206
- - examples/ranking/config/environments/production.rb
207
- - examples/ranking/config/environments/test.rb
208
- - examples/ranking/config/initializers/cors.rb
209
- - examples/ranking/config/initializers/filter_parameter_logging.rb
210
- - examples/ranking/config/initializers/inflections.rb
211
- - examples/ranking/config/initializers/timescale.rb
212
- - examples/ranking/config/locales/en.yml
213
- - examples/ranking/config/puma.rb
214
- - examples/ranking/config/routes.rb
215
- - examples/ranking/config/storage.yml
216
- - examples/ranking/db/migrate/20220209120747_create_games.rb
217
- - examples/ranking/db/migrate/20220209120910_create_plays.rb
218
- - examples/ranking/db/migrate/20220209143347_create_score_per_hours.rb
219
- - examples/ranking/db/schema.rb
220
- - examples/ranking/db/seeds.rb
221
- - examples/ranking/db/views/score_per_hours_v01.sql
222
- - examples/ranking/lib/tasks/.keep
223
- - examples/ranking/log/.keep
224
- - examples/ranking/public/robots.txt
225
- - examples/ranking/storage/.keep
226
- - examples/ranking/tmp/.keep
227
- - examples/ranking/tmp/pids/.keep
228
- - examples/ranking/tmp/storage/.keep
229
- - examples/ranking/vendor/.keep
230
- - examples/toolkit-demo/compare_volatility.rb
231
- - examples/toolkit-demo/lttb-zoom/README.md
232
- - examples/toolkit-demo/lttb-zoom/lttb_zoomable.rb
233
- - examples/toolkit-demo/lttb-zoom/views/index.erb
234
- - examples/toolkit-demo/lttb/README.md
235
- - examples/toolkit-demo/lttb/lttb.rb
236
- - examples/toolkit-demo/lttb/lttb_sinatra.rb
237
- - examples/toolkit-demo/lttb/lttb_test.rb
238
- - examples/toolkit-demo/lttb/views/index.erb
239
- - examples/toolkit-demo/ohlc.rb
240
149
  - lib/timescaledb.rb
241
150
  - lib/timescaledb/acts_as_hypertable.rb
242
151
  - lib/timescaledb/acts_as_hypertable/core.rb
@@ -244,7 +153,15 @@ files:
244
153
  - lib/timescaledb/application_record.rb
245
154
  - lib/timescaledb/chunk.rb
246
155
  - lib/timescaledb/compression_settings.rb
156
+ - lib/timescaledb/connection.rb
157
+ - lib/timescaledb/connection_handling.rb
247
158
  - lib/timescaledb/continuous_aggregates.rb
159
+ - lib/timescaledb/database.rb
160
+ - lib/timescaledb/database/chunk_statements.rb
161
+ - lib/timescaledb/database/hypertable_statements.rb
162
+ - lib/timescaledb/database/quoting.rb
163
+ - lib/timescaledb/database/schema_statements.rb
164
+ - lib/timescaledb/database/types.rb
248
165
  - lib/timescaledb/dimensions.rb
249
166
  - lib/timescaledb/hypertable.rb
250
167
  - lib/timescaledb/job.rb
@@ -253,13 +170,16 @@ files:
253
170
  - lib/timescaledb/scenic/adapter.rb
254
171
  - lib/timescaledb/scenic/extension.rb
255
172
  - lib/timescaledb/schema_dumper.rb
173
+ - lib/timescaledb/stats.rb
174
+ - lib/timescaledb/stats/chunks.rb
175
+ - lib/timescaledb/stats/continuous_aggregates.rb
176
+ - lib/timescaledb/stats/hypertables.rb
177
+ - lib/timescaledb/stats/job_stats.rb
256
178
  - lib/timescaledb/stats_report.rb
257
179
  - lib/timescaledb/toolkit.rb
258
180
  - lib/timescaledb/toolkit/helpers.rb
259
181
  - lib/timescaledb/toolkit/time_vector.rb
260
182
  - lib/timescaledb/version.rb
261
- - mkdocs.yml
262
- - timescaledb.gemspec
263
183
  homepage: https://github.com/jonatas/timescaledb
264
184
  licenses:
265
185
  - MIT
@@ -1,72 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- pull_request:
6
- workflow_dispatch:
7
- # schedule:
8
- # - cron: '42 5 * * *'
9
-
10
- jobs:
11
- test-in-container:
12
- strategy:
13
- fail-fast: false
14
- matrix:
15
- ruby: [ '3.1.2' ]
16
- database:
17
- - 'pg14.6-ts2.9.0-patroni-static-primary-latest'
18
- - 'pg13.9-ts2.9-latest'
19
-
20
- services:
21
- database:
22
- image: timescale/timescaledb-ha:${{matrix.database}}
23
- env:
24
- POSTGRES_USER: username
25
- POSTGRES_PASSWORD: secret
26
- POSTGRES_DB: testdb
27
- options: >-
28
- --health-cmd pg_isready
29
- --health-interval 10s
30
- --health-timeout 5s
31
- --health-retries 5
32
-
33
-
34
- runs-on: ubuntu-latest
35
- name: OS Ruby ${{matrix.ruby}} database ${{matrix.database}}
36
- container: ruby:${{matrix.ruby}}
37
-
38
- steps:
39
- - uses: actions/checkout@v3
40
-
41
- - name: Show Ruby Version
42
- run: |
43
- ruby -v
44
-
45
- - name: Install psql
46
- run: |
47
- apt-get update
48
- apt-get install -y postgresql-client
49
-
50
- - name: Show PostgreSQL version and time
51
- env:
52
- PGPASSWORD: secret
53
- run: |
54
- echo "SELECT version()" | psql -h database -U username testdb
55
- echo "SELECT CURRENT_TIME" | psql -h database -U username testdb
56
-
57
- - name: Setup
58
- run: |
59
- ./bin/setup
60
-
61
- - name: run tsdb
62
- run: ./bin/tsdb postgres://username:secret@database:5432/testdb --stats
63
-
64
- - name: Test setup
65
- run: |
66
- echo PG_URI_TEST="postgres://username:secret@database:5432/testdb" > .env
67
- cat .env
68
- bundle exec rake test:setup
69
-
70
- - name: Test
71
- run: bundle exec rake
72
-
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
- .env
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.1.2
data/.tool-versions DELETED
@@ -1 +0,0 @@
1
- ruby 2.7.1
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 3.1.2
6
- before_install: gem install bundler
7
- gemfile:
8
- - Gemfile
9
- - Gemfile.scenic