timescaledb 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/.tool-versions +1 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +11 -3
  7. data/Gemfile.scenic +7 -0
  8. data/Gemfile.scenic.lock +121 -0
  9. data/README.md +267 -121
  10. data/Rakefile +16 -1
  11. data/bin/console +2 -2
  12. data/bin/setup +2 -0
  13. data/bin/tsdb +30 -6
  14. data/examples/{Gemfile → all_in_one/Gemfile} +1 -1
  15. data/examples/{Gemfile.lock → all_in_one/Gemfile.lock} +2 -2
  16. data/examples/{all_in_one.rb → all_in_one/all_in_one.rb} +3 -6
  17. data/examples/ranking/.gitattributes +7 -0
  18. data/examples/ranking/.gitignore +29 -0
  19. data/examples/ranking/.ruby-version +1 -0
  20. data/examples/ranking/Gemfile +33 -0
  21. data/examples/ranking/Gemfile.lock +189 -0
  22. data/examples/ranking/README.md +166 -0
  23. data/examples/ranking/Rakefile +6 -0
  24. data/examples/ranking/app/controllers/application_controller.rb +2 -0
  25. data/examples/ranking/app/controllers/concerns/.keep +0 -0
  26. data/examples/ranking/app/jobs/application_job.rb +7 -0
  27. data/examples/ranking/app/models/application_record.rb +3 -0
  28. data/examples/ranking/app/models/concerns/.keep +0 -0
  29. data/examples/ranking/app/models/game.rb +2 -0
  30. data/examples/ranking/app/models/play.rb +7 -0
  31. data/examples/ranking/bin/bundle +114 -0
  32. data/examples/ranking/bin/rails +4 -0
  33. data/examples/ranking/bin/rake +4 -0
  34. data/examples/ranking/bin/setup +33 -0
  35. data/examples/ranking/config/application.rb +39 -0
  36. data/examples/ranking/config/boot.rb +4 -0
  37. data/examples/ranking/config/credentials.yml.enc +1 -0
  38. data/examples/ranking/config/database.yml +86 -0
  39. data/examples/ranking/config/environment.rb +5 -0
  40. data/examples/ranking/config/environments/development.rb +60 -0
  41. data/examples/ranking/config/environments/production.rb +75 -0
  42. data/examples/ranking/config/environments/test.rb +53 -0
  43. data/examples/ranking/config/initializers/cors.rb +16 -0
  44. data/examples/ranking/config/initializers/filter_parameter_logging.rb +8 -0
  45. data/examples/ranking/config/initializers/inflections.rb +16 -0
  46. data/examples/ranking/config/initializers/timescale.rb +3 -0
  47. data/examples/ranking/config/locales/en.yml +33 -0
  48. data/examples/ranking/config/puma.rb +43 -0
  49. data/examples/ranking/config/routes.rb +6 -0
  50. data/examples/ranking/config/storage.yml +34 -0
  51. data/examples/ranking/config.ru +6 -0
  52. data/examples/ranking/db/migrate/20220209120747_create_games.rb +10 -0
  53. data/examples/ranking/db/migrate/20220209120910_create_plays.rb +19 -0
  54. data/examples/ranking/db/migrate/20220209143347_create_score_per_hours.rb +5 -0
  55. data/examples/ranking/db/schema.rb +47 -0
  56. data/examples/ranking/db/seeds.rb +7 -0
  57. data/examples/ranking/db/views/score_per_hours_v01.sql +7 -0
  58. data/examples/ranking/lib/tasks/.keep +0 -0
  59. data/examples/ranking/log/.keep +0 -0
  60. data/examples/ranking/public/robots.txt +1 -0
  61. data/examples/ranking/storage/.keep +0 -0
  62. data/examples/ranking/tmp/.keep +0 -0
  63. data/examples/ranking/tmp/pids/.keep +0 -0
  64. data/examples/ranking/tmp/storage/.keep +0 -0
  65. data/examples/ranking/vendor/.keep +0 -0
  66. data/lib/timescaledb/acts_as_hypertable/core.rb +87 -0
  67. data/lib/timescaledb/acts_as_hypertable.rb +62 -0
  68. data/lib/{timescale → timescaledb}/chunk.rb +9 -1
  69. data/lib/{timescale → timescaledb}/compression_settings.rb +3 -2
  70. data/lib/timescaledb/continuous_aggregates.rb +19 -0
  71. data/lib/timescaledb/dimensions.rb +6 -0
  72. data/lib/{timescale → timescaledb}/hypertable.rb +9 -5
  73. data/lib/timescaledb/job.rb +10 -0
  74. data/lib/{timescale → timescaledb}/job_stats.rb +3 -4
  75. data/lib/{timescale → timescaledb}/migration_helpers.rb +35 -5
  76. data/lib/timescaledb/scenic/adapter.rb +55 -0
  77. data/lib/timescaledb/scenic/extension.rb +72 -0
  78. data/lib/timescaledb/schema_dumper.rb +88 -0
  79. data/lib/timescaledb/stats_report.rb +35 -0
  80. data/lib/timescaledb/version.rb +3 -0
  81. data/lib/timescaledb.rb +64 -0
  82. data/{timescale.gemspec → timescaledb.gemspec} +6 -4
  83. metadata +106 -20
  84. data/lib/timescale/acts_as_hypertable.rb +0 -114
  85. data/lib/timescale/continuous_aggregates.rb +0 -9
  86. data/lib/timescale/job.rb +0 -13
  87. data/lib/timescale/stats_report.rb +0 -28
  88. data/lib/timescale/version.rb +0 -3
  89. data/lib/timescale.rb +0 -52
@@ -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"
@@ -0,0 +1,189 @@
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
+ actioncable (7.0.2)
13
+ actionpack (= 7.0.2)
14
+ activesupport (= 7.0.2)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailbox (7.0.2)
18
+ actionpack (= 7.0.2)
19
+ activejob (= 7.0.2)
20
+ activerecord (= 7.0.2)
21
+ activestorage (= 7.0.2)
22
+ activesupport (= 7.0.2)
23
+ mail (>= 2.7.1)
24
+ net-imap
25
+ net-pop
26
+ net-smtp
27
+ actionmailer (7.0.2)
28
+ actionpack (= 7.0.2)
29
+ actionview (= 7.0.2)
30
+ activejob (= 7.0.2)
31
+ activesupport (= 7.0.2)
32
+ mail (~> 2.5, >= 2.5.4)
33
+ net-imap
34
+ net-pop
35
+ net-smtp
36
+ rails-dom-testing (~> 2.0)
37
+ actionpack (7.0.2)
38
+ actionview (= 7.0.2)
39
+ activesupport (= 7.0.2)
40
+ rack (~> 2.0, >= 2.2.0)
41
+ rack-test (>= 0.6.3)
42
+ rails-dom-testing (~> 2.0)
43
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
44
+ actiontext (7.0.2)
45
+ actionpack (= 7.0.2)
46
+ activerecord (= 7.0.2)
47
+ activestorage (= 7.0.2)
48
+ activesupport (= 7.0.2)
49
+ globalid (>= 0.6.0)
50
+ nokogiri (>= 1.8.5)
51
+ actionview (7.0.2)
52
+ activesupport (= 7.0.2)
53
+ builder (~> 3.1)
54
+ erubi (~> 1.4)
55
+ rails-dom-testing (~> 2.0)
56
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
57
+ activejob (7.0.2)
58
+ activesupport (= 7.0.2)
59
+ globalid (>= 0.3.6)
60
+ activemodel (7.0.2)
61
+ activesupport (= 7.0.2)
62
+ activerecord (7.0.2)
63
+ activemodel (= 7.0.2)
64
+ activesupport (= 7.0.2)
65
+ activestorage (7.0.2)
66
+ actionpack (= 7.0.2)
67
+ activejob (= 7.0.2)
68
+ activerecord (= 7.0.2)
69
+ activesupport (= 7.0.2)
70
+ marcel (~> 1.0)
71
+ mini_mime (>= 1.1.0)
72
+ activesupport (7.0.2)
73
+ concurrent-ruby (~> 1.0, >= 1.0.2)
74
+ i18n (>= 1.6, < 2)
75
+ minitest (>= 5.1)
76
+ tzinfo (~> 2.0)
77
+ bootsnap (1.10.3)
78
+ msgpack (~> 1.2)
79
+ builder (3.2.4)
80
+ coderay (1.1.3)
81
+ concurrent-ruby (1.1.9)
82
+ crass (1.0.6)
83
+ digest (3.1.0)
84
+ erubi (1.10.0)
85
+ globalid (1.0.0)
86
+ activesupport (>= 5.0)
87
+ i18n (1.9.1)
88
+ concurrent-ruby (~> 1.0)
89
+ io-wait (0.2.1)
90
+ loofah (2.13.0)
91
+ crass (~> 1.0.2)
92
+ nokogiri (>= 1.5.9)
93
+ mail (2.7.1)
94
+ mini_mime (>= 0.1.1)
95
+ marcel (1.0.2)
96
+ method_source (1.0.0)
97
+ mini_mime (1.1.2)
98
+ mini_portile2 (2.7.1)
99
+ minitest (5.15.0)
100
+ msgpack (1.4.4)
101
+ net-imap (0.2.3)
102
+ digest
103
+ net-protocol
104
+ strscan
105
+ net-pop (0.1.1)
106
+ digest
107
+ net-protocol
108
+ timeout
109
+ net-protocol (0.1.2)
110
+ io-wait
111
+ timeout
112
+ net-smtp (0.3.1)
113
+ digest
114
+ net-protocol
115
+ timeout
116
+ nio4r (2.5.8)
117
+ nokogiri (1.13.1)
118
+ mini_portile2 (~> 2.7.0)
119
+ racc (~> 1.4)
120
+ pg (1.3.1)
121
+ pry (0.14.1)
122
+ coderay (~> 1.1)
123
+ method_source (~> 1.0)
124
+ pry-rails (0.3.9)
125
+ pry (>= 0.10.4)
126
+ puma (5.6.1)
127
+ nio4r (~> 2.0)
128
+ racc (1.6.0)
129
+ rack (2.2.3)
130
+ rack-test (1.1.0)
131
+ rack (>= 1.0, < 3)
132
+ rails (7.0.2)
133
+ actioncable (= 7.0.2)
134
+ actionmailbox (= 7.0.2)
135
+ actionmailer (= 7.0.2)
136
+ actionpack (= 7.0.2)
137
+ actiontext (= 7.0.2)
138
+ actionview (= 7.0.2)
139
+ activejob (= 7.0.2)
140
+ activemodel (= 7.0.2)
141
+ activerecord (= 7.0.2)
142
+ activestorage (= 7.0.2)
143
+ activesupport (= 7.0.2)
144
+ bundler (>= 1.15.0)
145
+ railties (= 7.0.2)
146
+ rails-dom-testing (2.0.3)
147
+ activesupport (>= 4.2.0)
148
+ nokogiri (>= 1.6)
149
+ rails-html-sanitizer (1.4.2)
150
+ loofah (~> 2.3)
151
+ railties (7.0.2)
152
+ actionpack (= 7.0.2)
153
+ activesupport (= 7.0.2)
154
+ method_source
155
+ rake (>= 12.2)
156
+ thor (~> 1.0)
157
+ zeitwerk (~> 2.5)
158
+ rake (13.0.6)
159
+ scenic (1.5.5)
160
+ activerecord (>= 4.0.0)
161
+ railties (>= 4.0.0)
162
+ strscan (3.0.1)
163
+ thor (1.2.1)
164
+ timeout (0.2.0)
165
+ tzinfo (2.0.4)
166
+ concurrent-ruby (~> 1.0)
167
+ websocket-driver (0.7.5)
168
+ websocket-extensions (>= 0.1.0)
169
+ websocket-extensions (0.1.5)
170
+ zeitwerk (2.5.4)
171
+
172
+ PLATFORMS
173
+ ruby
174
+
175
+ DEPENDENCIES
176
+ bootsnap
177
+ pg (~> 1.1)
178
+ pry-rails
179
+ puma (~> 5.0)
180
+ rails (~> 7.0.2)
181
+ scenic (~> 1.5)
182
+ timescaledb!
183
+ tzinfo-data
184
+
185
+ RUBY VERSION
186
+ ruby 2.7.1p83
187
+
188
+ BUNDLED WITH
189
+ 2.1.4
@@ -0,0 +1,166 @@
1
+ # README
2
+
3
+ This example application is a "Scoring" service that stores "games" and "plays" of the games in question.
4
+
5
+ There are two tables:
6
+
7
+ * `games` that holds a name and description
8
+ * `plays` is a [hypertable][hypertable] that references a `game`, storing `score` and `total_time`.
9
+
10
+ Interesting things to observe here:
11
+
12
+ * The gem is required on [config/initializers/timescale.rb](./config/initializers/timescale.rb).
13
+ * The [hypertable creation](db/migrate/20220209120910_create_plays.rb) is also with the `enable_extension` command time.
14
+ * See how the [play model](app/models/play.rb) uses [acts_as_hypertable](../../lib/timescale/acts_as_hypertable.rb).
15
+
16
+ ## Walkthrough
17
+
18
+ Use `bin/console` to preload the environment and follow the next steps.
19
+
20
+ Let's start by creating a game and a single play.
21
+
22
+ ```ruby
23
+ lol = Game.create(name: "LoL", description: "League of Legends")
24
+ Play.create(game: lol,
25
+ score: (rand * 100).to_i,
26
+ total_time: (rand * 1000).to_i)
27
+ ```
28
+ You can also insert a few hundreds/thousands/millions of records to test it properly.
29
+
30
+ ```ruby
31
+ 100.times do
32
+ Play.create(game: lol,
33
+ score: (rand * 100).to_i,
34
+ total_time: (rand * 1000).to_i)
35
+ end
36
+ ```
37
+
38
+ You can play with multiple games and millions of play records to make it an impressive playground if you want :wink:
39
+
40
+
41
+ Then you can experiment with the [time_bucket][time_bucket] funciton.
42
+
43
+ ```ruby
44
+ Play.group("time_bucket('1 min',created_at)").count
45
+ # => {2022-02-09 12:34:00 UTC=>1, 2022-02-09 12:39:00 UTC=>10100}
46
+ ```
47
+
48
+ > Hypertables in TimescaleDB are designed to be easy to manage and to behave predictably to users familiar with standard PostgreSQL tables. Along those lines, SQL commands to create, alter, or delete hypertables in TimescaleDB are identical to those in PostgreSQL. Even though hypertables are comprised of many interlinked chunks, commands made to the hypertable automatically propagate changes down to all of the chunks belonging to that hypertable.
49
+
50
+ When the model contains the `acts_as_hypertable` macro, it's possible to navigate into the hypertable internals:
51
+
52
+ ```ruby
53
+ Play.hypertable
54
+ # => #<Timescaledb::Hypertable:0x00007faa97df7e30
55
+ # hypertable_schema: "public",
56
+ # hypertable_name: "plays",
57
+ # owner: "jonatasdp",
58
+ # num_dimensions: 1,
59
+ # num_chunks: 2,
60
+ # compression_enabled: true,
61
+ # is_distributed: false,
62
+ # replication_factor: nil,
63
+ # data_nodes: nil,
64
+ # tablespaces: nil>
65
+ ```
66
+
67
+ Each hypertable has many chunks. Chunks are the subtables spread accross the time. You can check chunks metadata from the `hypertable` relation here:
68
+
69
+ ```ruby
70
+ Play.hypertable.chunks.pluck(:chunk_name)
71
+ # => ["_hyper_1_1_chunk", "_hyper_1_2_chunk"]
72
+ ```
73
+
74
+ Chunks can also be compressed/decompressed and you can check the state using scopes:
75
+
76
+ ```ruby
77
+ Play.hypertable.chunks.compressed.count # => 2
78
+ ```
79
+
80
+ Get a resume from chunks status:
81
+
82
+ ```ruby
83
+ Play.hypertable.chunks.resume
84
+ # => {:total=>2, :compressed=>0, :uncompressed=>2}
85
+ ```
86
+
87
+ To get a full stats from all hypertables, you can see `Timescaledb.stats`:
88
+
89
+ ```ruby
90
+ Timescaledb.stats
91
+ # => {:hypertables=>
92
+ # {:count=>1,
93
+ # :uncompressed=>0,
94
+ # :approximate_row_count=>{"plays"=>10100},
95
+ # :chunks=>{:total=>2, :compressed=>0, :uncompressed=>2},
96
+ # :size=>{:uncompressed=>"1.3 MB", :compressed=>"0 Bytes"}},
97
+ # :continuous_aggregates=>{:total=>0},
98
+ # :jobs_stats=>[{:success=>100, :runs=>100, :failures=>0}]}
99
+ ```
100
+ Note that we haven't used compression yet. So, we can force compression directly from the `chunk` relation:
101
+
102
+ ```ruby
103
+ Play.hypertable.chunks.each(&:compress!)
104
+ ```
105
+
106
+ Calling `stats` to check the compressed size:
107
+
108
+ ```ruby
109
+ Timescaledb.stats
110
+ # {:count=>1, ...
111
+ # :size=>
112
+ # {:uncompressed=>"1.2 MB",
113
+ # :compressed=>"180 KB"}},
114
+ # :continuous_aggregates=>{:total=>0},
115
+ # :jobs_stats=>
116
+ # [{:success=>107,
117
+ # :runs=>107,
118
+ # :failures=>0}]}
119
+ ```
120
+
121
+ > :warning: Note that the chunks are not very effective compressing here because of the example is incomplete and with a little amount of records.
122
+
123
+ You can decompress as the system will make the compression in the background as it already have a policy.
124
+
125
+ ```ruby
126
+ Play.hypertable.chunks.each(&:decompress!)
127
+ ```
128
+
129
+ ## Dump schema
130
+
131
+ The lib also contains a [schema_dumper](../../lib/timescale/schema_dumper.rb) that allows you to dump the schema and reload with the same hypertable options.
132
+
133
+ ```bash
134
+ rails db:schema:dump
135
+ ```
136
+
137
+ Confirm that the hypertable is on [db/schema.rb](db/schema.rb) file:
138
+
139
+ ```
140
+ grep hypertable db/schema.rb
141
+ create_hypertable "plays", time_column: "created_at", chunk_time_interval: "1
142
+ minute", compress_segmentby: "game_id", compress_orderby: "created_at ASC",
143
+ compression_interval: "P7D"
144
+ ```
145
+
146
+ And you can also reload the configuration manually in the test environment:
147
+
148
+ ```bash
149
+ RAILS_ENV=test rails db:schema:load
150
+ ```
151
+
152
+ ## Scenic views
153
+
154
+ If you use [scenic](https://github.com/scenic-views/scenic) views, it will
155
+ automatically recognize and dump the views.
156
+
157
+ Check the [view migration](db/migrate/20220209143347_create_score_per_hours.rb)
158
+ and the correspondent view defined in the [sql file](db/views/score_per_hours_v01.sql).
159
+
160
+ > Note that scenic is not fully compatible with timescaledb continous aggregates
161
+ > and we created a [helper](../../lib/timescale/scenic/extension.rb) to make it
162
+ > easy to use along with scenic.
163
+
164
+ [hypertable]: https://docs.timescale.com/timescaledb/latest/how-to-guides/hypertables/
165
+ [time_bucket]: https://docs.timescale.com/api/latest/hyperfunctions/time_bucket/
166
+
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative "config/application"
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::API
2
+ end
File without changes
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ primary_abstract_class
3
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ class Game < ApplicationRecord
2
+ end
@@ -0,0 +1,7 @@
1
+ class Play < ApplicationRecord
2
+ belongs_to :game
3
+
4
+ self.primary_key = "created_at"
5
+
6
+ acts_as_hypertable
7
+ end
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "rake"
4
+ Rake.application.run
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path("..", __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts "== Installing dependencies =="
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?("config/database.yml")
22
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! "bin/rails db:prepare"
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! "bin/rails log:clear tmp:clear"
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! "bin/rails restart"
33
+ end
@@ -0,0 +1,39 @@
1
+ require_relative "boot"
2
+
3
+ require "rails"
4
+ # Pick the frameworks you want:
5
+ require "active_model/railtie"
6
+ require "active_job/railtie"
7
+ require "active_record/railtie"
8
+ require "active_storage/engine"
9
+ require "action_controller/railtie"
10
+ # require "action_mailer/railtie"
11
+ require "action_mailbox/engine"
12
+ require "action_text/engine"
13
+ require "action_view/railtie"
14
+ # require "action_cable/engine"
15
+ # require "rails/test_unit/railtie"
16
+
17
+ # Require the gems listed in Gemfile, including any gems
18
+ # you've limited to :test, :development, or :production.
19
+ Bundler.require(*Rails.groups)
20
+
21
+ module Ranking
22
+ class Application < Rails::Application
23
+ # Initialize configuration defaults for originally generated Rails version.
24
+ config.load_defaults 7.0
25
+
26
+ # Configuration for the application, engines, and railties goes here.
27
+ #
28
+ # These settings can be overridden in specific environments using the files
29
+ # in config/environments, which are processed later.
30
+ #
31
+ # config.time_zone = "Central Time (US & Canada)"
32
+ # config.eager_load_paths << Rails.root.join("extras")
33
+
34
+ # Only loads a smaller set of middleware suitable for API only apps.
35
+ # Middleware like session, flash, cookies can be added back manually.
36
+ # Skip views, helpers and assets when generating a new resource.
37
+ config.api_only = true
38
+ end
39
+ end
@@ -0,0 +1,4 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
4
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
@@ -0,0 +1 @@
1
+ 89mWxkKPY+RpiS3ysJ0FE9ljcVzmhiJVCYL9MVKwqPzkU/tUhehytnhibSz/ZNV/ef8WqOzYm5DfFfKXAXXixut/Aazw8725RxxLUDcikpy8ayr13WZgj91XlaPLCHPVyuNlxgVJFN8HPw++Xfe3pakKeJB0hhAlCgwCWIT7tx7Zf6g8KaIbdvJ+U9drEu3n4OgaQuw+wzRU1EaI80BbX1r9+Uufg6t7mWzMEh7n55HEBTinyNL/UZgQ0XvOQs+bQjjHVxRATXT2Mxt1zF3FZQZ6ECtOPKBKit9PDaS3RCkN2tk3ObvXlmSbz2vcIB/oW03M63TfjmfXjpG25N8tXqLl0MKoyOv/3UiBqeC7orNLTXZuWxpaQyCjpTqmza/rQyPkTRsUt+V1Rtw1gZfMbTK/JOdXr1feMhrl--91mPoTmwkbiDY9sK--49vaWMgJTV11y2bdEDMgug==