timescaledb 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/lib/timescaledb/acts_as_hypertable/core.rb +1 -1
  3. data/lib/timescaledb/database/quoting.rb +12 -0
  4. data/lib/timescaledb/database/schema_statements.rb +168 -0
  5. data/lib/timescaledb/database/types.rb +17 -0
  6. data/lib/timescaledb/database.rb +11 -0
  7. data/lib/timescaledb/toolkit/time_vector.rb +41 -4
  8. data/lib/timescaledb/version.rb +1 -1
  9. metadata +6 -95
  10. data/.github/workflows/ci.yml +0 -72
  11. data/.gitignore +0 -12
  12. data/.rspec +0 -3
  13. data/.ruby-version +0 -1
  14. data/.tool-versions +0 -1
  15. data/.travis.yml +0 -9
  16. data/CODE_OF_CONDUCT.md +0 -74
  17. data/Fastfile +0 -17
  18. data/Gemfile +0 -8
  19. data/Gemfile.lock +0 -75
  20. data/Gemfile.scenic +0 -7
  21. data/Gemfile.scenic.lock +0 -119
  22. data/README.md +0 -490
  23. data/Rakefile +0 -21
  24. data/bin/console +0 -28
  25. data/bin/setup +0 -13
  26. data/docs/command_line.md +0 -178
  27. data/docs/img/lttb_example.png +0 -0
  28. data/docs/img/lttb_sql_vs_ruby.gif +0 -0
  29. data/docs/img/lttb_zoom.gif +0 -0
  30. data/docs/index.md +0 -72
  31. data/docs/migrations.md +0 -76
  32. data/docs/models.md +0 -78
  33. data/docs/toolkit.md +0 -507
  34. data/docs/toolkit_lttb_tutorial.md +0 -557
  35. data/docs/toolkit_lttb_zoom.md +0 -357
  36. data/docs/toolkit_ohlc.md +0 -315
  37. data/docs/videos.md +0 -16
  38. data/examples/all_in_one/all_in_one.rb +0 -94
  39. data/examples/all_in_one/benchmark_comparison.rb +0 -108
  40. data/examples/all_in_one/caggs.rb +0 -93
  41. data/examples/all_in_one/query_data.rb +0 -78
  42. data/examples/ranking/.gitattributes +0 -7
  43. data/examples/ranking/.gitignore +0 -29
  44. data/examples/ranking/.ruby-version +0 -1
  45. data/examples/ranking/Gemfile +0 -33
  46. data/examples/ranking/Gemfile.lock +0 -189
  47. data/examples/ranking/README.md +0 -166
  48. data/examples/ranking/Rakefile +0 -6
  49. data/examples/ranking/app/controllers/application_controller.rb +0 -2
  50. data/examples/ranking/app/controllers/concerns/.keep +0 -0
  51. data/examples/ranking/app/jobs/application_job.rb +0 -7
  52. data/examples/ranking/app/models/application_record.rb +0 -3
  53. data/examples/ranking/app/models/concerns/.keep +0 -0
  54. data/examples/ranking/app/models/game.rb +0 -2
  55. data/examples/ranking/app/models/play.rb +0 -7
  56. data/examples/ranking/bin/bundle +0 -114
  57. data/examples/ranking/bin/rails +0 -4
  58. data/examples/ranking/bin/rake +0 -4
  59. data/examples/ranking/bin/setup +0 -33
  60. data/examples/ranking/config/application.rb +0 -39
  61. data/examples/ranking/config/boot.rb +0 -4
  62. data/examples/ranking/config/credentials.yml.enc +0 -1
  63. data/examples/ranking/config/database.yml +0 -86
  64. data/examples/ranking/config/environment.rb +0 -5
  65. data/examples/ranking/config/environments/development.rb +0 -60
  66. data/examples/ranking/config/environments/production.rb +0 -75
  67. data/examples/ranking/config/environments/test.rb +0 -53
  68. data/examples/ranking/config/initializers/cors.rb +0 -16
  69. data/examples/ranking/config/initializers/filter_parameter_logging.rb +0 -8
  70. data/examples/ranking/config/initializers/inflections.rb +0 -16
  71. data/examples/ranking/config/initializers/timescale.rb +0 -2
  72. data/examples/ranking/config/locales/en.yml +0 -33
  73. data/examples/ranking/config/puma.rb +0 -43
  74. data/examples/ranking/config/routes.rb +0 -6
  75. data/examples/ranking/config/storage.yml +0 -34
  76. data/examples/ranking/config.ru +0 -6
  77. data/examples/ranking/db/migrate/20220209120747_create_games.rb +0 -10
  78. data/examples/ranking/db/migrate/20220209120910_create_plays.rb +0 -19
  79. data/examples/ranking/db/migrate/20220209143347_create_score_per_hours.rb +0 -5
  80. data/examples/ranking/db/schema.rb +0 -47
  81. data/examples/ranking/db/seeds.rb +0 -7
  82. data/examples/ranking/db/views/score_per_hours_v01.sql +0 -7
  83. data/examples/ranking/lib/tasks/.keep +0 -0
  84. data/examples/ranking/log/.keep +0 -0
  85. data/examples/ranking/public/robots.txt +0 -1
  86. data/examples/ranking/storage/.keep +0 -0
  87. data/examples/ranking/tmp/.keep +0 -0
  88. data/examples/ranking/tmp/pids/.keep +0 -0
  89. data/examples/ranking/tmp/storage/.keep +0 -0
  90. data/examples/ranking/vendor/.keep +0 -0
  91. data/examples/toolkit-demo/compare_volatility.rb +0 -104
  92. data/examples/toolkit-demo/lttb/README.md +0 -15
  93. data/examples/toolkit-demo/lttb/lttb.rb +0 -92
  94. data/examples/toolkit-demo/lttb/lttb_sinatra.rb +0 -139
  95. data/examples/toolkit-demo/lttb/lttb_test.rb +0 -21
  96. data/examples/toolkit-demo/lttb/views/index.erb +0 -27
  97. data/examples/toolkit-demo/lttb-zoom/README.md +0 -13
  98. data/examples/toolkit-demo/lttb-zoom/lttb_zoomable.rb +0 -90
  99. data/examples/toolkit-demo/lttb-zoom/views/index.erb +0 -33
  100. data/examples/toolkit-demo/ohlc.rb +0 -175
  101. data/mkdocs.yml +0 -34
  102. data/timescaledb.gemspec +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06f324ce8793264ad6acb6a0f0f8f107511be08ecf2952e2fab285aeac366d35
4
- data.tar.gz: d95da2805b53dafd174bb83fce7cf29cc2f13b5e8543bfa144d424e679aba701
3
+ metadata.gz: 9281749307a9161088f45af47b26ac9577d693e03958c351eee257467b706428
4
+ data.tar.gz: 5a3ef9e484416b56091d62eaff9c3063ca19d441a893e022c10ebe17d4997241
5
5
  SHA512:
6
- metadata.gz: 14ce31badc6ae1eae1f51161a806354fcaea6b2d39197498766b4cefa2022565410f7fc745adfbaf0d51b68d67454460f3aabab2a94444dd377a93193d0465b2
7
- data.tar.gz: 573dd6b5ae3bcfa0948176a86561c080a860d72634e1800b750554a694e17a17890a31492e2702b38ced8444b5725586bfcca6cb23109c968748edeb509bcf12
6
+ metadata.gz: 37f96329e32067e2d891f1ea8c40f3b2af4e6b4422f1a6a47593013b70092f95207e9d1b6ddc8708f342fede9395e92951b52a04d57bafb1eb4bdeecd29c481b
7
+ data.tar.gz: 4fdb61ef0fae73b217c2f14791f29bfb1dfe0b447c3a26c95f2a78d2ecf9ed97de2f14b8c3af0741dab91dac3746430a5281e0f98c4a97279fd62506fb2ceba7
@@ -75,7 +75,7 @@ module Timescaledb
75
75
 
76
76
  scope :yesterday, -> { where("DATE(#{time_column}) = ?", Date.yesterday.in_time_zone.to_date) }
77
77
  scope :today, -> { where("DATE(#{time_column}) = ?", Date.today.in_time_zone.to_date) }
78
- scope :last_hour, -> { where("#{time_column} > ?", 1.hour.ago.in_time_zone) }
78
+ scope :last_hour, -> { where("#{time_column} between ? and ?", 1.hour.ago.in_time_zone, Time.now.end_of_hour.in_time_zone) }
79
79
  end
80
80
 
81
81
  def normalize_hypertable_options
@@ -0,0 +1,12 @@
1
+ module Timescaledb
2
+ class Database
3
+ module Quoting
4
+ # Quotes given value and escapes single quote and backslash characters.
5
+ #
6
+ # @return [String] The given value between quotes
7
+ def quote(value)
8
+ "'#{value.gsub("\\", '\&\&').gsub("'", "''")}'"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,168 @@
1
+ module Timescaledb
2
+ class Database
3
+ module SchemaStatements
4
+ # @see https://docs.timescale.com/api/latest/hypertable/create_hypertable/#create_hypertable
5
+ #
6
+ # @param [String] relation The identifier of the table to convert to hypertable
7
+ # @param [String] time_column_name The name of the column containing time values as well as the primary column to partition by
8
+ # @param [Hash] options The optional arguments
9
+ # @return [String] The create_hypertable SQL statement
10
+ def create_hypertable_sql(relation, time_column_name, **options)
11
+ options.transform_keys!(&:to_sym)
12
+
13
+ partitioning_column = options.delete(:partitioning_column)
14
+ number_partitions = options.delete(:number_partitions)
15
+
16
+ arguments = [quote(relation), quote(time_column_name)]
17
+ arguments += [quote(partitioning_column), number_partitions] if partitioning_column && number_partitions
18
+ arguments += cast_create_hypertable_optional_arguments(options)
19
+
20
+ "SELECT create_hypertable(#{arguments.join(', ')});"
21
+ end
22
+
23
+ # @see https://docs.timescale.com/api/latest/compression/alter_table_compression/#alter-table-compression
24
+ #
25
+ # @param [String] hypertable The name of the hypertable to enable compression
26
+ # @param [Hash] options The optional arguments
27
+ # @return [String] The ALTER TABLE SQL to enable compression
28
+ def enable_hypertable_compression_sql(hypertable, **options)
29
+ options.transform_keys!(&:to_sym)
30
+
31
+ compress_orderby = options.delete(:compress_orderby)
32
+ compress_segmentby = options.delete(:compress_segmentby)
33
+
34
+ arguments = ['timescaledb.compress']
35
+ arguments << "timescaledb.compress_orderby = #{quote(compress_orderby)}" if compress_orderby
36
+ arguments << "timescaledb.compress_segmentby = #{quote(compress_segmentby)}" if compress_segmentby
37
+
38
+ "ALTER TABLE #{hypertable} SET (#{arguments.join(', ')});"
39
+ end
40
+
41
+ # @see https://docs.timescale.com/api/latest/compression/alter_table_compression/#alter-table-compression
42
+ #
43
+ # @param [String] hypertable The name of the hypertable to disable compression
44
+ # @return [String] The ALTER TABLE SQL to disable compression
45
+ def disable_hypertable_compression_sql(hypertable)
46
+ "ALTER TABLE #{hypertable} SET (timescaledb.compress = FALSE);"
47
+ end
48
+
49
+ # @see https://docs.timescale.com/api/latest/compression/add_compression_policy/#add_compression_policy
50
+ #
51
+ # @param [String] hypertable The name of the hypertable or continuous aggregate to create the policy for
52
+ # @param [String] compress_after The age after which the policy job compresses chunks
53
+ # @param [Hash] options The optional arguments
54
+ # @return [String] The add_compression_policy SQL statement
55
+ def add_compression_policy_sql(hypertable, compress_after, **options)
56
+ options.transform_keys!(&:to_sym)
57
+
58
+ arguments = [quote(hypertable), interval_to_sql(compress_after)]
59
+ arguments += cast_policy_optional_arguments(options)
60
+
61
+ "SELECT add_compression_policy(#{arguments.join(', ')});"
62
+ end
63
+
64
+ # @see https://docs.timescale.com/api/latest/compression/remove_compression_policy/#remove_compression_policy
65
+ #
66
+ # @param [String] hypertable The name of the hypertable to remove the policy from
67
+ # @param [Hash] options The optional arguments
68
+ # @return [String] The remove_compression_policy SQL statement
69
+ def remove_compression_policy_sql(hypertable, **options)
70
+ options.transform_keys!(&:to_sym)
71
+
72
+ arguments = [quote(hypertable)]
73
+ arguments += cast_policy_optional_arguments(options)
74
+
75
+ "SELECT remove_compression_policy(#{arguments.join(', ')});"
76
+ end
77
+
78
+ # @see https://docs.timescale.com/api/latest/data-retention/add_retention_policy/#add_retention_policy
79
+ #
80
+ # @param [String] hypertable The name of the hypertable to create the policy for
81
+ # @param [String] drop_after The age after which the policy job drops chunks
82
+ # @param [Hash] options The optional arguments
83
+ # @return [String] The add_retention_policy SQL statement
84
+ def add_retention_policy_sql(hypertable, drop_after, **options)
85
+ options.transform_keys!(&:to_sym)
86
+
87
+ arguments = [quote(hypertable), interval_to_sql(drop_after)]
88
+ arguments += cast_policy_optional_arguments(options)
89
+
90
+ "SELECT add_retention_policy(#{arguments.join(', ')});"
91
+ end
92
+
93
+ # @see https://docs.timescale.com/api/latest/data-retention/remove_retention_policy/#remove_retention_policy
94
+ #
95
+ # @param [String] hypertable The name of the hypertable to remove the policy from
96
+ # @param [Hash] options The optional arguments
97
+ # @return [String] The remove_retention_policy SQL statement
98
+ def remove_retention_policy_sql(hypertable, **options)
99
+ options.transform_keys!(&:to_sym)
100
+
101
+ arguments = [quote(hypertable)]
102
+ arguments += cast_policy_optional_arguments(options)
103
+
104
+ "SELECT remove_retention_policy(#{arguments.join(', ')});"
105
+ end
106
+
107
+ # @see https://docs.timescale.com/api/latest/hypertable/add_reorder_policy/#add_reorder_policy
108
+ #
109
+ # @param [String] hypertable The name of the hypertable to create the policy for
110
+ # @param [String] index_name The existing index by which to order rows on disk
111
+ # @param [Hash] options The optional arguments
112
+ # @return [String] The add_reorder_policy SQL statement
113
+ def add_reorder_policy_sql(hypertable, index_name, **options)
114
+ options.transform_keys!(&:to_sym)
115
+
116
+ arguments = [quote(hypertable), quote(index_name)]
117
+ arguments += cast_policy_optional_arguments(options)
118
+
119
+ "SELECT add_reorder_policy(#{arguments.join(', ')});"
120
+ end
121
+
122
+ # @see https://docs.timescale.com/api/latest/hypertable/remove_reorder_policy/#remove_reorder_policy
123
+ #
124
+ # @param [String] hypertable The name of the hypertable to remove the policy from
125
+ # @param [Hash] options The optional arguments
126
+ # @return [String] The remove_retention_policy SQL statement
127
+ def remove_reorder_policy_sql(hypertable, **options)
128
+ options.transform_keys!(&:to_sym)
129
+
130
+ arguments = [quote(hypertable)]
131
+ arguments += cast_policy_optional_arguments(options)
132
+
133
+ "SELECT remove_reorder_policy(#{arguments.join(', ')});"
134
+ end
135
+
136
+ private
137
+
138
+ # @param [Array<Hash<Symbol, Object>>] options The policy optional arguments.
139
+ # @return [Array<String>]
140
+ def cast_policy_optional_arguments(options)
141
+ options.map do |option, value|
142
+ case option
143
+ when :if_not_exists, :if_exists then "#{option} => #{boolean_to_sql(value)}"
144
+ when :initial_start, :timezone then "#{option} => #{quote(value)}"
145
+ end
146
+ end.compact
147
+ end
148
+
149
+ # @param [Array<Hash<Symbol, Object>>] options The create_hypertable optional arguments.
150
+ # @return [Array<String>]
151
+ def cast_create_hypertable_optional_arguments(options)
152
+ options.map do |option, value|
153
+ case option
154
+ when :chunk_time_interval
155
+ "#{option} => #{interval_to_sql(value)}"
156
+ when :if_not_exists, :create_default_indexes, :migrate_data, :distributed
157
+ "#{option} => #{boolean_to_sql(value)}"
158
+ when :partitioning_func, :associated_schema_name,
159
+ :associated_table_prefix, :time_partitioning_func
160
+ "#{option} => #{quote(value)}"
161
+ when :replication_factor
162
+ "#{option} => #{value}"
163
+ end
164
+ end.compact
165
+ end
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,17 @@
1
+ module Timescaledb
2
+ class Database
3
+ module Types
4
+ # @param [String] interval The interval value
5
+ # @return [String]
6
+ def interval_to_sql(interval)
7
+ "INTERVAL #{quote(interval)}"
8
+ end
9
+
10
+ # @param [String] boolean The boolean value
11
+ # @return [String]
12
+ def boolean_to_sql(boolean)
13
+ quote(boolean ? 'TRUE' : 'FALSE')
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ require_relative 'database/quoting'
2
+ require_relative 'database/schema_statements'
3
+ require_relative 'database/types'
4
+
5
+ module Timescaledb
6
+ class Database
7
+ extend Quoting
8
+ extend SchemaStatements
9
+ extend Types
10
+ end
11
+ 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,18 +59,55 @@ module Timescaledb
59
59
  end
60
60
 
61
61
 
62
+ scope :_candlestick, -> (timeframe: '1h',
63
+ segment_by: segment_by_column,
64
+ time: time_column,
65
+ volume: 'volume',
66
+ value: value_column) do
67
+
68
+ select( %|time_bucket('#{timeframe}', "#{time}")|,
69
+ *segment_by,
70
+ "toolkit_experimental.candlestick_agg(#{time}, #{value}, #{volume}) as candlestick")
71
+ .order(1)
72
+ .group(*(segment_by ? [1,2] : 1))
73
+ end
74
+
75
+ scope :candlestick, -> (timeframe: '1h',
76
+ segment_by: segment_by_column,
77
+ time: time_column,
78
+ volume: 'volume',
79
+ value: value_column) do
80
+
81
+ raw = _candlestick(timeframe: timeframe, segment_by: segment_by, time: time, value: value, volume: volume)
82
+ unscoped
83
+ .from("(#{raw.to_sql}) AS candlestick")
84
+ .select("time_bucket",*segment_by,
85
+ "toolkit_experimental.open(candlestick),
86
+ toolkit_experimental.high(candlestick),
87
+ toolkit_experimental.low(candlestick),
88
+ toolkit_experimental.close(candlestick),
89
+ toolkit_experimental.open_time(candlestick),
90
+ toolkit_experimental.high_time(candlestick),
91
+ toolkit_experimental.low_time(candlestick),
92
+ toolkit_experimental.close_time(candlestick),
93
+ toolkit_experimental.volume(candlestick),
94
+ toolkit_experimental.vwap(candlestick)")
95
+ end
96
+
62
97
  scope :_ohlc, -> (timeframe: '1h',
63
98
  segment_by: segment_by_column,
64
99
  time: time_column,
65
100
  value: value_column) do
66
101
 
67
- select( "time_bucket('#{timeframe}', #{time}) as #{time}",
68
- *segment_by,
69
- "toolkit_experimental.ohlc(#{time}, #{value})")
102
+ select( *segment_by,
103
+ %|time_bucket('#{timeframe}', #{time}) as "#{time}"|,
104
+ "toolkit_experimental.ohlc(#{time}, #{value})")
70
105
  .order(1)
71
106
  .group(*(segment_by ? [1,2] : 1))
72
107
  end
73
108
 
109
+
110
+
74
111
  scope :ohlc, -> (timeframe: '1h',
75
112
  segment_by: segment_by_column,
76
113
  time: time_column,
@@ -1,3 +1,3 @@
1
1
  module Timescaledb
2
- VERSION = '0.2.6'
2
+ VERSION = '0.2.7'
3
3
  end
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.7
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: 2023-02-06 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
@@ -245,6 +154,10 @@ files:
245
154
  - lib/timescaledb/chunk.rb
246
155
  - lib/timescaledb/compression_settings.rb
247
156
  - lib/timescaledb/continuous_aggregates.rb
157
+ - lib/timescaledb/database.rb
158
+ - lib/timescaledb/database/quoting.rb
159
+ - lib/timescaledb/database/schema_statements.rb
160
+ - lib/timescaledb/database/types.rb
248
161
  - lib/timescaledb/dimensions.rb
249
162
  - lib/timescaledb/hypertable.rb
250
163
  - lib/timescaledb/job.rb
@@ -258,8 +171,6 @@ files:
258
171
  - lib/timescaledb/toolkit/helpers.rb
259
172
  - lib/timescaledb/toolkit/time_vector.rb
260
173
  - lib/timescaledb/version.rb
261
- - mkdocs.yml
262
- - timescaledb.gemspec
263
174
  homepage: https://github.com/jonatas/timescaledb
264
175
  licenses:
265
176
  - 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
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at jonatasdp@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [https://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
data/Fastfile DELETED
@@ -1,17 +0,0 @@
1
-
2
- # Use `fast .version_up` to rewrite the version file
3
- Fast.shortcut :version_up do
4
- rewrite_file('(casgn nil VERSION (str _)', 'lib/timescaledb/version.rb') do |node|
5
- target = node.children.last.loc.expression
6
- pieces = target.source.split('.').map(&:to_i)
7
- pieces.reverse.each_with_index do |fragment, i|
8
- if fragment < 9
9
- pieces[-(i + 1)] = fragment + 1
10
- break
11
- else
12
- pieces[-(i + 1)] = 0
13
- end
14
- end
15
- replace(target, "'#{pieces.join('.')}'")
16
- end
17
- end
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in timescale.gemspec
4
- gemspec
5
-
6
- # gemika must be listed in the Gemfile rather than as a development dependency in the gemspec.
7
- # It throws an error, otherwise.
8
- gem "gemika"