timescaledb 0.1.4 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/.tool-versions +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +6 -3
- data/Gemfile.scenic +7 -0
- data/Gemfile.scenic.lock +121 -0
- data/README.md +35 -18
- data/Rakefile +7 -1
- data/bin/console +3 -3
- data/bin/setup +2 -0
- data/bin/tsdb +7 -7
- data/examples/{Gemfile → all_in_one/Gemfile} +0 -0
- data/examples/{Gemfile.lock → all_in_one/Gemfile.lock} +0 -0
- data/examples/{all_in_one.rb → all_in_one/all_in_one.rb} +1 -1
- data/examples/ranking/.gitattributes +7 -0
- data/examples/ranking/.gitignore +29 -0
- data/examples/ranking/.ruby-version +1 -0
- data/examples/ranking/Gemfile +33 -0
- data/examples/ranking/Gemfile.lock +189 -0
- data/examples/ranking/README.md +166 -0
- data/examples/ranking/Rakefile +6 -0
- data/examples/ranking/app/controllers/application_controller.rb +2 -0
- data/examples/ranking/app/controllers/concerns/.keep +0 -0
- data/examples/ranking/app/jobs/application_job.rb +7 -0
- data/examples/ranking/app/models/application_record.rb +3 -0
- data/examples/ranking/app/models/concerns/.keep +0 -0
- data/examples/ranking/app/models/game.rb +2 -0
- data/examples/ranking/app/models/play.rb +7 -0
- data/examples/ranking/bin/bundle +114 -0
- data/examples/ranking/bin/rails +4 -0
- data/examples/ranking/bin/rake +4 -0
- data/examples/ranking/bin/setup +33 -0
- data/examples/ranking/config/application.rb +39 -0
- data/examples/ranking/config/boot.rb +4 -0
- data/examples/ranking/config/credentials.yml.enc +1 -0
- data/examples/ranking/config/database.yml +86 -0
- data/examples/ranking/config/environment.rb +5 -0
- data/examples/ranking/config/environments/development.rb +60 -0
- data/examples/ranking/config/environments/production.rb +75 -0
- data/examples/ranking/config/environments/test.rb +53 -0
- data/examples/ranking/config/initializers/cors.rb +16 -0
- data/examples/ranking/config/initializers/filter_parameter_logging.rb +8 -0
- data/examples/ranking/config/initializers/inflections.rb +16 -0
- data/examples/ranking/config/initializers/timescale.rb +2 -0
- data/examples/ranking/config/locales/en.yml +33 -0
- data/examples/ranking/config/puma.rb +43 -0
- data/examples/ranking/config/routes.rb +6 -0
- data/examples/ranking/config/storage.yml +34 -0
- data/examples/ranking/config.ru +6 -0
- data/examples/ranking/db/migrate/20220209120747_create_games.rb +10 -0
- data/examples/ranking/db/migrate/20220209120910_create_plays.rb +19 -0
- data/examples/ranking/db/migrate/20220209143347_create_score_per_hours.rb +5 -0
- data/examples/ranking/db/schema.rb +47 -0
- data/examples/ranking/db/seeds.rb +7 -0
- data/examples/ranking/db/views/score_per_hours_v01.sql +7 -0
- data/examples/ranking/lib/tasks/.keep +0 -0
- data/examples/ranking/log/.keep +0 -0
- data/examples/ranking/public/robots.txt +1 -0
- data/examples/ranking/storage/.keep +0 -0
- data/examples/ranking/tmp/.keep +0 -0
- data/examples/ranking/tmp/pids/.keep +0 -0
- data/examples/ranking/tmp/storage/.keep +0 -0
- data/examples/ranking/vendor/.keep +0 -0
- data/lib/{timescale → timescaledb}/acts_as_hypertable/core.rb +1 -1
- data/lib/{timescale → timescaledb}/acts_as_hypertable.rb +6 -6
- data/lib/{timescale → timescaledb}/chunk.rb +1 -1
- data/lib/{timescale → timescaledb}/compression_settings.rb +3 -2
- data/lib/{timescale → timescaledb}/continuous_aggregates.rb +5 -4
- data/lib/timescaledb/dimensions.rb +6 -0
- data/lib/{timescale → timescaledb}/hypertable.rb +5 -5
- data/lib/timescaledb/job.rb +10 -0
- data/lib/{timescale → timescaledb}/job_stats.rb +3 -4
- data/lib/{timescale → timescaledb}/migration_helpers.rb +51 -13
- data/lib/timescaledb/scenic/adapter.rb +55 -0
- data/lib/timescaledb/scenic/extension.rb +72 -0
- data/lib/timescaledb/schema_dumper.rb +91 -0
- data/lib/{timescale → timescaledb}/stats_report.rb +2 -2
- data/lib/timescaledb/version.rb +3 -0
- data/lib/timescaledb.rb +64 -0
- data/{timescale.gemspec → timescaledb.gemspec} +5 -4
- metadata +92 -23
- data/lib/timescale/dimensions.rb +0 -7
- data/lib/timescale/job.rb +0 -13
- data/lib/timescale/schema_dumper.rb +0 -24
- data/lib/timescale/version.rb +0 -3
- data/lib/timescale.rb +0 -50
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/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.1
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.1
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
timescaledb (0.1
|
4
|
+
timescaledb (0.2.1)
|
5
5
|
activerecord
|
6
|
+
activesupport
|
6
7
|
pg (~> 1.2)
|
7
8
|
|
8
9
|
GEM
|
@@ -27,11 +28,12 @@ GEM
|
|
27
28
|
database_cleaner-core (2.0.1)
|
28
29
|
diff-lcs (1.4.4)
|
29
30
|
dotenv (2.7.6)
|
31
|
+
gemika (0.6.1)
|
30
32
|
i18n (1.8.10)
|
31
33
|
concurrent-ruby (~> 1.0)
|
32
34
|
method_source (1.0.0)
|
33
35
|
minitest (5.14.4)
|
34
|
-
pg (1.
|
36
|
+
pg (1.3.1)
|
35
37
|
pry (0.14.1)
|
36
38
|
coderay (~> 1.1)
|
37
39
|
method_source (~> 1.0)
|
@@ -62,6 +64,7 @@ PLATFORMS
|
|
62
64
|
DEPENDENCIES
|
63
65
|
database_cleaner-active_record
|
64
66
|
dotenv
|
67
|
+
gemika
|
65
68
|
pry
|
66
69
|
rake (~> 12.0)
|
67
70
|
rspec (~> 3.0)
|
@@ -69,4 +72,4 @@ DEPENDENCIES
|
|
69
72
|
timescaledb!
|
70
73
|
|
71
74
|
BUNDLED WITH
|
72
|
-
2.
|
75
|
+
2.2.31
|
data/Gemfile.scenic
ADDED
data/Gemfile.scenic.lock
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
timescaledb (0.1.5)
|
5
|
+
activerecord
|
6
|
+
activesupport
|
7
|
+
pg (~> 1.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionpack (6.1.4.1)
|
13
|
+
actionview (= 6.1.4.1)
|
14
|
+
activesupport (= 6.1.4.1)
|
15
|
+
rack (~> 2.0, >= 2.0.9)
|
16
|
+
rack-test (>= 0.6.3)
|
17
|
+
rails-dom-testing (~> 2.0)
|
18
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
19
|
+
actionview (6.1.4.1)
|
20
|
+
activesupport (= 6.1.4.1)
|
21
|
+
builder (~> 3.1)
|
22
|
+
erubi (~> 1.4)
|
23
|
+
rails-dom-testing (~> 2.0)
|
24
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
25
|
+
activemodel (6.1.4.1)
|
26
|
+
activesupport (= 6.1.4.1)
|
27
|
+
activerecord (6.1.4.1)
|
28
|
+
activemodel (= 6.1.4.1)
|
29
|
+
activesupport (= 6.1.4.1)
|
30
|
+
activesupport (6.1.4.1)
|
31
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
32
|
+
i18n (>= 1.6, < 2)
|
33
|
+
minitest (>= 5.1)
|
34
|
+
tzinfo (~> 2.0)
|
35
|
+
zeitwerk (~> 2.3)
|
36
|
+
builder (3.2.4)
|
37
|
+
coderay (1.1.3)
|
38
|
+
concurrent-ruby (1.1.9)
|
39
|
+
crass (1.0.6)
|
40
|
+
database_cleaner-active_record (2.0.1)
|
41
|
+
activerecord (>= 5.a)
|
42
|
+
database_cleaner-core (~> 2.0.0)
|
43
|
+
database_cleaner-core (2.0.1)
|
44
|
+
diff-lcs (1.4.4)
|
45
|
+
dotenv (2.7.6)
|
46
|
+
erubi (1.10.0)
|
47
|
+
gemika (0.6.1)
|
48
|
+
i18n (1.8.11)
|
49
|
+
concurrent-ruby (~> 1.0)
|
50
|
+
loofah (2.12.0)
|
51
|
+
crass (~> 1.0.2)
|
52
|
+
nokogiri (>= 1.5.9)
|
53
|
+
method_source (1.0.0)
|
54
|
+
mini_portile2 (2.6.1)
|
55
|
+
minitest (5.14.4)
|
56
|
+
nokogiri (1.12.5)
|
57
|
+
mini_portile2 (~> 2.6.1)
|
58
|
+
racc (~> 1.4)
|
59
|
+
nokogiri (1.12.5-x86_64-darwin)
|
60
|
+
racc (~> 1.4)
|
61
|
+
pg (1.3.0)
|
62
|
+
pry (0.14.1)
|
63
|
+
coderay (~> 1.1)
|
64
|
+
method_source (~> 1.0)
|
65
|
+
racc (1.6.0)
|
66
|
+
rack (2.2.3)
|
67
|
+
rack-test (1.1.0)
|
68
|
+
rack (>= 1.0, < 3)
|
69
|
+
rails-dom-testing (2.0.3)
|
70
|
+
activesupport (>= 4.2.0)
|
71
|
+
nokogiri (>= 1.6)
|
72
|
+
rails-html-sanitizer (1.4.2)
|
73
|
+
loofah (~> 2.3)
|
74
|
+
railties (6.1.4.1)
|
75
|
+
actionpack (= 6.1.4.1)
|
76
|
+
activesupport (= 6.1.4.1)
|
77
|
+
method_source
|
78
|
+
rake (>= 0.13)
|
79
|
+
thor (~> 1.0)
|
80
|
+
rake (12.3.3)
|
81
|
+
rspec (3.10.0)
|
82
|
+
rspec-core (~> 3.10.0)
|
83
|
+
rspec-expectations (~> 3.10.0)
|
84
|
+
rspec-mocks (~> 3.10.0)
|
85
|
+
rspec-core (3.10.1)
|
86
|
+
rspec-support (~> 3.10.0)
|
87
|
+
rspec-expectations (3.10.1)
|
88
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
89
|
+
rspec-support (~> 3.10.0)
|
90
|
+
rspec-its (1.3.0)
|
91
|
+
rspec-core (>= 3.0.0)
|
92
|
+
rspec-expectations (>= 3.0.0)
|
93
|
+
rspec-mocks (3.10.2)
|
94
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
95
|
+
rspec-support (~> 3.10.0)
|
96
|
+
rspec-support (3.10.3)
|
97
|
+
scenic (1.5.4)
|
98
|
+
activerecord (>= 4.0.0)
|
99
|
+
railties (>= 4.0.0)
|
100
|
+
thor (1.1.0)
|
101
|
+
tzinfo (2.0.4)
|
102
|
+
concurrent-ruby (~> 1.0)
|
103
|
+
zeitwerk (2.5.1)
|
104
|
+
|
105
|
+
PLATFORMS
|
106
|
+
ruby
|
107
|
+
x86_64-darwin-20
|
108
|
+
|
109
|
+
DEPENDENCIES
|
110
|
+
database_cleaner-active_record
|
111
|
+
dotenv
|
112
|
+
gemika
|
113
|
+
pry
|
114
|
+
rake (~> 12.0)
|
115
|
+
rspec (~> 3.0)
|
116
|
+
rspec-its
|
117
|
+
scenic
|
118
|
+
timescaledb!
|
119
|
+
|
120
|
+
BUNDLED WITH
|
121
|
+
2.2.33
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# TimescaleDB
|
2
2
|
|
3
|
-
Welcome to the
|
3
|
+
Welcome to the TimescaleDB gem! To experiment with the code, start installing the
|
4
4
|
gem:
|
5
5
|
|
6
6
|
```bash
|
@@ -29,7 +29,7 @@ tsdb postgres://<user>@localhost:5432/<dbname> --stats
|
|
29
29
|
Or just check the stats:
|
30
30
|
|
31
31
|
```bash
|
32
|
-
tsdb "postgres://jonatasdp@localhost:5432/
|
32
|
+
tsdb "postgres://jonatasdp@localhost:5432/timescaledb_test" --stats
|
33
33
|
```
|
34
34
|
|
35
35
|
These is a sample output from database example with almost no data:
|
@@ -89,7 +89,7 @@ continuous aggregates views.
|
|
89
89
|
|
90
90
|
```ruby
|
91
91
|
Tick
|
92
|
-
=>
|
92
|
+
=> Timescaledb::Tick(time: datetime, symbol: string, price: decimal, volume: integer)
|
93
93
|
```
|
94
94
|
|
95
95
|
Note that it's only created for this session and will never be cached in the
|
@@ -102,7 +102,7 @@ Let's start with the `.hypertable` method.
|
|
102
102
|
|
103
103
|
```ruby
|
104
104
|
Tick.hypertable
|
105
|
-
=> #<
|
105
|
+
=> #<Timescaledb::Hypertable:0x00007fe99c258900
|
106
106
|
hypertable_schema: "public",
|
107
107
|
hypertable_name: "ticks",
|
108
108
|
owner: "jonatasdp",
|
@@ -122,7 +122,7 @@ from the hypertable relation.
|
|
122
122
|
```ruby
|
123
123
|
Tick.hypertable.chunks
|
124
124
|
unknown OID 2206: failed to recognize type of 'primary_dimension_type'. It will be treated as String.
|
125
|
-
=> [#<
|
125
|
+
=> [#<Timescaledb::Chunk:0x00007fe99c31b068
|
126
126
|
hypertable_schema: "public",
|
127
127
|
hypertable_name: "ticks",
|
128
128
|
chunk_schema: "_timescaledb_internal",
|
@@ -175,14 +175,14 @@ The `ohlc_1m` view is also available as an ActiveRecord:
|
|
175
175
|
|
176
176
|
```ruby
|
177
177
|
Ohlc1m
|
178
|
-
=>
|
178
|
+
=> Timescaledb::Ohlc1m(bucket: datetime, symbol: string, open: decimal, high: decimal, low: decimal, close: decimal, volume: integer)
|
179
179
|
```
|
180
180
|
|
181
181
|
And you can run any query as you do with regular active record queries.
|
182
182
|
|
183
183
|
```ruby
|
184
184
|
Ohlc1m.order(bucket: :desc).last
|
185
|
-
=> #<
|
185
|
+
=> #<Timescaledb::Ohlc1m:0x00007fe99c2c38e0
|
186
186
|
bucket: 2000-01-01 00:00:00 UTC,
|
187
187
|
symbol: "SYMBOL",
|
188
188
|
open: 0.13e2,
|
@@ -211,7 +211,9 @@ Or install it yourself as:
|
|
211
211
|
|
212
212
|
## Usage
|
213
213
|
|
214
|
-
|
214
|
+
Check the [examples/ranking](examples/ranking) to get a Rails complete example.
|
215
|
+
|
216
|
+
You can check the [all_in_one.rb](examples/all_in_one/all_in_one.rb) example that will:
|
215
217
|
|
216
218
|
1. Create hypertable with compression settings
|
217
219
|
2. Insert data
|
@@ -221,6 +223,11 @@ You can check the [all_in_one.rb](examples/all_in_one.rb) that will:
|
|
221
223
|
6. Check chunk status
|
222
224
|
7. Decompress a chunk
|
223
225
|
|
226
|
+
### Testing
|
227
|
+
|
228
|
+
If you need some inspiration for how are you going to test your hypertables,
|
229
|
+
please check the [spec/spec_helper.rb](spec/spec_helper.rb) for inspiration.
|
230
|
+
|
224
231
|
### Migrations
|
225
232
|
|
226
233
|
Create table is now with the `hypertable` keyword allowing to pass a few options
|
@@ -243,7 +250,7 @@ create_table(:events, id: false, hypertable: hypertable_options) do |t|
|
|
243
250
|
end
|
244
251
|
```
|
245
252
|
|
246
|
-
####
|
253
|
+
#### create_continuous_aggregate
|
247
254
|
|
248
255
|
This example shows a ticks table grouping ticks as OHLCV histograms for every
|
249
256
|
minute.
|
@@ -287,9 +294,19 @@ options = {
|
|
287
294
|
}
|
288
295
|
}
|
289
296
|
|
290
|
-
|
297
|
+
create_continuous_aggregate('ohlc_1m', query, **options)
|
291
298
|
```
|
292
299
|
|
300
|
+
#### Scenic integration
|
301
|
+
|
302
|
+
The [Scenic](https://github.com/scenic-views/scenic) gem is an easy way to
|
303
|
+
manage database view definitions for a Rails application. TimescaleDB's
|
304
|
+
continuous aggregates are more complex than regular PostgreSQL views, and
|
305
|
+
the schema dumper included with Scenic can't dump a complete definition.
|
306
|
+
|
307
|
+
This gem automatically configures Scenic to use a `Timescaledb::Scenic::Adapter`
|
308
|
+
which will correctly handle schema dumping.
|
309
|
+
|
293
310
|
### Enable ActsAsHypertable
|
294
311
|
|
295
312
|
You can declare a Rails model as a Hypertable by invoking the `acts_as_hypertable` macro. This macro extends your existing model with timescaledb-related functionality.
|
@@ -318,7 +335,7 @@ end
|
|
318
335
|
To get all the chunks from a model's hypertable, you can use `.chunks`.
|
319
336
|
|
320
337
|
```ruby
|
321
|
-
Event.chunks # => [#<
|
338
|
+
Event.chunks # => [#<Timescaledb::Chunk>, ...]
|
322
339
|
```
|
323
340
|
|
324
341
|
### Hypertable metadata
|
@@ -326,20 +343,20 @@ Event.chunks # => [#<Timescale::Chunk>, ...]
|
|
326
343
|
To get the models' hypertable metadata, you can use `.hypertable`.
|
327
344
|
|
328
345
|
```ruby
|
329
|
-
Event.hypertable # => #<
|
346
|
+
Event.hypertable # => #<Timescaledb::Hypertable>
|
330
347
|
```
|
331
348
|
|
332
|
-
To get hypertable metadata for all hypertables: `
|
349
|
+
To get hypertable metadata for all hypertables: `Timescaledb.hypertables`.
|
333
350
|
|
334
351
|
### Compression Settings
|
335
352
|
|
336
353
|
Compression settings are accessible through the hypertable.
|
337
354
|
|
338
355
|
```ruby
|
339
|
-
Event.hypertable.compression_settings # => [#<
|
356
|
+
Event.hypertable.compression_settings # => [#<Timescaledb::CompressionSettings>, ...]
|
340
357
|
```
|
341
358
|
|
342
|
-
To get compression settings for all hypertables: `
|
359
|
+
To get compression settings for all hypertables: `Timescaledb.compression_settings`.
|
343
360
|
|
344
361
|
### Scopes
|
345
362
|
|
@@ -388,7 +405,7 @@ end
|
|
388
405
|
|
389
406
|
## Development
|
390
407
|
|
391
|
-
After checking out the repo, run `bin/setup` to install the development dependencies. Then, `bundle exec rake test:setup` to setup the test database and tables. Finally, run `bundle exec
|
408
|
+
After checking out the repo, run `bin/setup` to install the development dependencies. Then, `bundle exec rake test:setup` to setup the test database and tables. Finally, run `bundle exec rake` to run the tests.
|
392
409
|
|
393
410
|
You can also run `tsdb` for an interactive prompt that will allow you to experiment.
|
394
411
|
|
@@ -405,7 +422,7 @@ You can put some postgres URI directly as a parameter of
|
|
405
422
|
`tsdb`. Here is an example from the console:
|
406
423
|
|
407
424
|
```bash
|
408
|
-
tsdb "postgres://jonatasdp@localhost:5432/
|
425
|
+
tsdb "postgres://jonatasdp@localhost:5432/timescaledb_test"
|
409
426
|
```
|
410
427
|
|
411
428
|
## More resources
|
data/Rakefile
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
|
4
|
+
begin
|
5
|
+
require "gemika/tasks"
|
6
|
+
rescue LoadError
|
7
|
+
puts "Run `gem install gemika` for additional tasks"
|
8
|
+
end
|
9
|
+
|
4
10
|
RSpec::Core::RakeTask.new(:spec)
|
5
11
|
|
6
|
-
task default: :spec
|
12
|
+
task default: "matrix:spec"
|
7
13
|
|
8
14
|
namespace :test do
|
9
15
|
task :setup do
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
|
-
require "
|
4
|
+
require "timescaledb"
|
5
5
|
|
6
6
|
def uri_from_test
|
7
7
|
require 'dotenv'
|
@@ -11,7 +11,7 @@ end
|
|
11
11
|
|
12
12
|
ActiveRecord::Base.establish_connection(ARGV[0] || uri_from_test)
|
13
13
|
|
14
|
-
|
14
|
+
Timescaledb::Hypertable.find_each do |hypertable|
|
15
15
|
class_name = hypertable.hypertable_name.singularize.camelize
|
16
16
|
|
17
17
|
model = Class.new(ActiveRecord::Base) do
|
@@ -21,7 +21,7 @@ Timescale::Hypertable.find_each do |hypertable|
|
|
21
21
|
acts_as_hypertable
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
Timescaledb.const_set(class_name, model)
|
25
25
|
end
|
26
26
|
|
27
27
|
require "pry"
|
data/bin/setup
CHANGED
data/bin/tsdb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "bundler/setup"
|
3
|
-
require "
|
3
|
+
require "timescaledb"
|
4
4
|
require "pry"
|
5
5
|
|
6
6
|
ActiveRecord::Base.establish_connection(ARGV[0])
|
7
7
|
|
8
|
-
|
8
|
+
Timescaledb::Hypertable.find_each do |hypertable|
|
9
9
|
class_name = hypertable.hypertable_name.singularize.camelize
|
10
10
|
model = Class.new(ActiveRecord::Base) do
|
11
11
|
self.table_name = hypertable.hypertable_name
|
12
12
|
acts_as_hypertable
|
13
13
|
end
|
14
|
-
|
14
|
+
Timescaledb.const_set(class_name, model)
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
Timescaledb::ContinuousAggregates.find_each do |cagg|
|
18
18
|
class_name = cagg.view_name.singularize.camelize
|
19
19
|
model = Class.new(ActiveRecord::Base) do
|
20
20
|
self.table_name = cagg.view_name
|
21
21
|
acts_as_hypertable
|
22
22
|
end
|
23
|
-
|
23
|
+
Timescaledb.const_set(class_name, model)
|
24
24
|
end
|
25
25
|
|
26
26
|
def show(obj)
|
@@ -28,7 +28,7 @@ def show(obj)
|
|
28
28
|
end
|
29
29
|
|
30
30
|
if ARGV.index("--stats")
|
31
|
-
scope =
|
31
|
+
scope = Timescaledb::Hypertable.all
|
32
32
|
|
33
33
|
if (only = ARGV.index("--only"))
|
34
34
|
only_hypertables = ARGV[only+1].split(",")
|
@@ -40,7 +40,7 @@ if ARGV.index("--stats")
|
|
40
40
|
scope = scope.where.not(hypertable_name: except_hypertables)
|
41
41
|
end
|
42
42
|
|
43
|
-
show(
|
43
|
+
show(Timescaledb.stats(scope))
|
44
44
|
end
|
45
45
|
|
46
46
|
if ARGV.index("--console")
|
File without changes
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore all logfiles and tempfiles.
|
11
|
+
/log/*
|
12
|
+
/tmp/*
|
13
|
+
!/log/.keep
|
14
|
+
!/tmp/.keep
|
15
|
+
|
16
|
+
# Ignore pidfiles, but keep the directory.
|
17
|
+
/tmp/pids/*
|
18
|
+
!/tmp/pids/
|
19
|
+
!/tmp/pids/.keep
|
20
|
+
|
21
|
+
# Ignore uploaded files in development.
|
22
|
+
/storage/*
|
23
|
+
!/storage/.keep
|
24
|
+
/tmp/storage/*
|
25
|
+
!/tmp/storage/
|
26
|
+
!/tmp/storage/.keep
|
27
|
+
|
28
|
+
# Ignore master key for decrypting credentials and more.
|
29
|
+
/config/master.key
|
@@ -0,0 +1 @@
|
|
1
|
+
2.7.1
|
@@ -0,0 +1,33 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
ruby "2.7.1"
|
5
|
+
|
6
|
+
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
|
7
|
+
gem "rails", "~> 7.0.2"
|
8
|
+
|
9
|
+
gem "timescaledb", path: "../../"
|
10
|
+
gem "pg", "~> 1.1"
|
11
|
+
gem "puma", "~> 5.0"
|
12
|
+
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
|
13
|
+
|
14
|
+
# Reduces boot times through caching; required in config/boot.rb
|
15
|
+
gem "bootsnap", require: false
|
16
|
+
|
17
|
+
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
18
|
+
# gem "image_processing", "~> 1.2"
|
19
|
+
|
20
|
+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
|
21
|
+
# gem "rack-cors"
|
22
|
+
|
23
|
+
group :development, :test do
|
24
|
+
gem "pry-rails"
|
25
|
+
end
|
26
|
+
|
27
|
+
group :development do
|
28
|
+
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
|
29
|
+
# gem "spring"
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
gem "scenic", "~> 1.5"
|