diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 230aafd40..f864924d6 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -27,7 +27,7 @@ jobs: if: ${{ steps.rb-changed.outputs.changed-files != ''}} uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1.4 + ruby-version: 3.3.7 bundler-cache: true - name: Run RuboCop diff --git a/Gemfile b/Gemfile index e324dfe1b..049ba7203 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" # We only pin versions to specific Git commits when they are "problem childs" # and we want to review each commit before updating to the latest version. -ruby "3.1.4" +ruby "3.3.7" gem "active_model_serializers", "~> 0.10" gem "activerecord-import", "~>1.7" @@ -19,6 +19,7 @@ gem "clipboard-rails", "~> 1.7" gem "coffee-rails", "~> 5.0" # CoffeeScript for .coffee assets and views gem "commontator", "~> 7.0.1" gem "coveralls", "~> 0.7", require: false +gem "csv", "~> 3.3" # silence warning: no longer part of default gems for Ruby >=3.4.0 gem "dalli", "~> 3.2" # caching to memcached in production gem "devise", "~> 4.9" gem "devise-bootstrap-views", "~> 1.1" @@ -46,7 +47,7 @@ gem "progress_bar", "~> 1.3" gem "prometheus_exporter", "~> 2.1" gem "puma", "~> 6.4" # app server gem "rack", "~> 2.2" -gem "rails", "~> 7.1.3" +gem "rails", "~> 7.2.2" gem "rails-i18n", "~> 7.0" gem "responders", "~> 3.1" gem "rgl", "~> 0.6" @@ -62,7 +63,7 @@ gem "sunspot_rails", "~> 2.7" gem "sunspot_solr", "~> 2.7" gem "terser", "~> 1.2" # Ruby wrapper for UglifyJS JavaScript compressor gem "thredded", git: "https://github.com/thredded/thredded.git", - ref: "1340e913affd1af5fcc060fbccd271184ece9a6a" + ref: "94fbf890a984527bab399c8c7f1eec7af7006843" gem "thredded-markdown_katex", git: "https://github.com/thredded/thredded-markdown_katex.git", ref: "e2830bdb40880018a0e59d2b82c94b0a9f237365" @@ -73,6 +74,7 @@ gem "webpacker", "~> 5.4" group :development, :docker_development do gem "listen", "~> 3.9" gem "marcel", "~> 1.0" + gem "mutex_m", "~> 0.3" # silence warning: no longer part of default gems for Ruby >=3.4.0 gem "pgreset", "~> 0.4" gem "rails-erd", "~> 1.7" gem "rubocop", "~> 1.65", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 5cc9a8130..3b2818270 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,8 +9,8 @@ GIT GIT remote: https://github.com/thredded/thredded.git - revision: 1340e913affd1af5fcc060fbccd271184ece9a6a - ref: 1340e913affd1af5fcc060fbccd271184ece9a6a + revision: 94fbf890a984527bab399c8c7f1eec7af7006843 + ref: 94fbf890a984527bab399c8c7f1eec7af7006843 specs: thredded (1.1.0) active_record_union (>= 1.3.0) @@ -26,11 +26,10 @@ GIT nokogiri onebox (>= 1.8.99) pundit (>= 1.1.0) - rails (> 6.0.0.rc2) + rails (>= 7.0) rails_gravatar rinku sanitize - sassc-rails (>= 2.0.0) sprockets-es6 timeago_js (>= 3.0.2.2) @@ -41,51 +40,46 @@ GEM RubyInline (3.14.1) ZenTest (~> 4.3) ZenTest (4.12.2) - actioncable (7.1.5.1) - actionpack (= 7.1.5.1) - activesupport (= 7.1.5.1) + actioncable (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.1.5.1) - actionpack (= 7.1.5.1) - activejob (= 7.1.5.1) - activerecord (= 7.1.5.1) - activestorage (= 7.1.5.1) - activesupport (= 7.1.5.1) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.5.1) - actionpack (= 7.1.5.1) - actionview (= 7.1.5.1) - activejob (= 7.1.5.1) - activesupport (= 7.1.5.1) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp + actionmailbox (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) + mail (>= 2.8.0) + actionmailer (7.2.2.1) + actionpack (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activesupport (= 7.2.2.1) + mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.1.5.1) - actionview (= 7.1.5.1) - activesupport (= 7.1.5.1) + actionpack (7.2.2.1) + actionview (= 7.2.2.1) + activesupport (= 7.2.2.1) nokogiri (>= 1.8.5) racc - rack (>= 2.2.4) + rack (>= 2.2.4, < 3.2) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actiontext (7.1.5.1) - actionpack (= 7.1.5.1) - activerecord (= 7.1.5.1) - activestorage (= 7.1.5.1) - activesupport (= 7.1.5.1) + useragent (~> 0.16) + actiontext (7.2.2.1) + actionpack (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.1.5.1) - activesupport (= 7.1.5.1) + actionview (7.2.2.1) + activesupport (= 7.2.2.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) @@ -97,38 +91,37 @@ GEM jsonapi-renderer (>= 0.1.1.beta1, < 0.3) active_record_union (1.3.0) activerecord (>= 4.0) - activejob (7.1.5.1) - activesupport (= 7.1.5.1) + activejob (7.2.2.1) + activesupport (= 7.2.2.1) globalid (>= 0.3.6) - activemodel (7.1.5.1) - activesupport (= 7.1.5.1) - activerecord (7.1.5.1) - activemodel (= 7.1.5.1) - activesupport (= 7.1.5.1) + activemodel (7.2.2.1) + activesupport (= 7.2.2.1) + activerecord (7.2.2.1) + activemodel (= 7.2.2.1) + activesupport (= 7.2.2.1) timeout (>= 0.4.0) activerecord-import (1.8.1) activerecord (>= 4.2) activerecord-nulldb-adapter (1.1.1) activerecord (>= 6.0, < 8.1) - activestorage (7.1.5.1) - actionpack (= 7.1.5.1) - activejob (= 7.1.5.1) - activerecord (= 7.1.5.1) - activesupport (= 7.1.5.1) + activestorage (7.2.2.1) + actionpack (= 7.2.2.1) + activejob (= 7.2.2.1) + activerecord (= 7.2.2.1) + activesupport (= 7.2.2.1) marcel (~> 1.0) - activesupport (7.1.5.1) + activesupport (7.2.2.1) base64 benchmark (>= 0.3) bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) logger (>= 1.4.2) minitest (>= 5.1) - mutex_m securerandom (>= 0.3) - tzinfo (~> 2.0) + tzinfo (~> 2.0, >= 2.0.5) acts_as_list (1.2.4) activerecord (>= 6.1) activesupport (>= 6.1) @@ -190,6 +183,7 @@ GEM crass (1.0.6) css_parser (1.21.0) addressable + csv (3.3.2) dalli (3.2.8) database_cleaner-active_record (2.2.0) activerecord (>= 5.a) @@ -327,7 +321,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - logger (1.6.5) + logger (1.6.6) loofah (2.24.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -352,18 +346,18 @@ GEM multipart-post (2.4.1) mustache (1.1.1) mutex_m (0.3.0) - net-imap (0.5.5) + net-imap (0.5.6) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout - net-smtp (0.5.0) + net-smtp (0.5.1) net-protocol netrc (0.11.0) nio4r (2.7.4) - nokogiri (1.18.2-x86_64-linux-gnu) + nokogiri (1.18.3-x86_64-linux-gnu) racc (~> 1.4) onebox (2.2.19) addressable (~> 2.8.0) @@ -415,7 +409,7 @@ GEM activesupport (>= 3.0.0) raabro (1.4.0) racc (1.8.1) - rack (2.2.10) + rack (2.2.11) rack-proxy (0.7.7) rack rack-session (1.0.2) @@ -425,20 +419,20 @@ GEM rackup (1.0.1) rack (< 3) webrick - rails (7.1.5.1) - actioncable (= 7.1.5.1) - actionmailbox (= 7.1.5.1) - actionmailer (= 7.1.5.1) - actionpack (= 7.1.5.1) - actiontext (= 7.1.5.1) - actionview (= 7.1.5.1) - activejob (= 7.1.5.1) - activemodel (= 7.1.5.1) - activerecord (= 7.1.5.1) - activestorage (= 7.1.5.1) - activesupport (= 7.1.5.1) + rails (7.2.2.1) + actioncable (= 7.2.2.1) + actionmailbox (= 7.2.2.1) + actionmailer (= 7.2.2.1) + actionpack (= 7.2.2.1) + actiontext (= 7.2.2.1) + actionview (= 7.2.2.1) + activejob (= 7.2.2.1) + activemodel (= 7.2.2.1) + activerecord (= 7.2.2.1) + activestorage (= 7.2.2.1) + activesupport (= 7.2.2.1) bundler (>= 1.15.0) - railties (= 7.1.5.1) + railties (= 7.2.2.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -456,10 +450,10 @@ GEM railties (>= 6.0.0, < 8) rails_gravatar (1.0.4) actionview - railties (7.1.5.1) - actionpack (= 7.1.5.1) - activesupport (= 7.1.5.1) - irb + railties (7.2.2.1) + actionpack (= 7.2.2.1) + activesupport (= 7.2.2.1) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) @@ -469,7 +463,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rdoc (6.11.0) + rdoc (6.12.0) psych (>= 4.0.0) redis-client (0.23.2) connection_pool @@ -486,7 +480,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.4.0) + rexml (3.4.1) rgl (0.6.6) pairing_heap (>= 0.3, < 4.0) rexml (~> 3.2, >= 3.2.4) @@ -602,7 +596,7 @@ GEM stream (0.5.5) streamio-ffmpeg (3.0.2) multi_json (~> 1.8) - stringio (3.1.2) + stringio (3.1.5) sunspot (2.7.1) bigdecimal pr_geohash (~> 1.0) @@ -636,6 +630,7 @@ GEM unicode-display_width (3.1.4) unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (4.0.4) + useragent (0.16.11) warden (1.2.9) rack (>= 2.0.9) web-console (4.2.1) @@ -654,7 +649,7 @@ GEM websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) will_paginate (4.0.1) - zeitwerk (2.6.18) + zeitwerk (2.7.2) PLATFORMS x86_64-linux @@ -676,6 +671,7 @@ DEPENDENCIES coffee-rails (~> 5.0) commontator (~> 7.0.1) coveralls (~> 0.7) + csv (~> 3.3) dalli (~> 3.2) database_cleaner-active_record (~> 2.2) devise (~> 4.9) @@ -700,6 +696,7 @@ DEPENDENCIES marcel (~> 1.0) mini_magick (~> 4.13) mobility (~> 1.2) + mutex_m (~> 0.3) net-smtp (~> 0.5) pdf-reader (~> 2.12) pg (~> 1.5) @@ -709,7 +706,7 @@ DEPENDENCIES prometheus_exporter (~> 2.1) puma (~> 6.4) rack (~> 2.2) - rails (~> 7.1.3) + rails (~> 7.2.2) rails-erd (~> 1.7) rails-i18n (~> 7.0) responders (~> 3.1) @@ -743,7 +740,7 @@ DEPENDENCIES webpacker (~> 5.4) RUBY VERSION - ruby 3.1.4p223 + ruby 3.3.7p123 BUNDLED WITH 2.6.3 diff --git a/app/helpers/email_helper.rb b/app/helpers/email_helper.rb index 1031b37fc..b2f485f46 100644 --- a/app/helpers/email_helper.rb +++ b/app/helpers/email_helper.rb @@ -1,6 +1,6 @@ module EmailHelper - def email_image_tag(image, **options) + def email_image_tag(image, **) attachments.inline[image] = Rails.root.join("public/#{image}").read - image_tag(attachments[image].url, **options) + image_tag(attachments[image].url, **) end end diff --git a/app/models/annotation.rb b/app/models/annotation.rb index 6ee3ec804..7e975af5f 100644 --- a/app/models/annotation.rb +++ b/app/models/annotation.rb @@ -9,8 +9,8 @@ class Annotation < ApplicationRecord # the timestamp for the annotation position is serialized as text in the db serialize :timestamp, coder: TimeStamp - enum category: { note: 0, content: 1, mistake: 2, presentation: 3 } - enum subcategory: { definition: 0, argument: 1, strategy: 2 } + enum :category, { note: 0, content: 1, mistake: 2, presentation: 3 } + enum :subcategory, { definition: 0, argument: 1, strategy: 2 } # If the annotation has an associated commontator comment, its comment will # be saved in the commontator comment. While calling annotation.comment returns diff --git a/app/models/interaction.rb b/app/models/interaction.rb index 87e8331a2..8e9847305 100644 --- a/app/models/interaction.rb +++ b/app/models/interaction.rb @@ -2,7 +2,6 @@ class Interaction < InteractionsRecord scope :created_between, lambda { |start_date, end_date| where(created_at: start_date.beginning_of_day..end_date.end_of_day) } - require "csv" def self.to_csv attributes = ["id", "session_id", "created_at", "full_path", "referrer_url", diff --git a/app/models/probe.rb b/app/models/probe.rb index 7de065442..83cacd148 100644 --- a/app/models/probe.rb +++ b/app/models/probe.rb @@ -2,7 +2,6 @@ class Probe < InteractionsRecord scope :created_between, lambda { |start_date, end_date| where(created_at: start_date.beginning_of_day..end_date.end_of_day) } - require "csv" def self.finished_quizzes(quiz) Probe.where(quiz_id: quiz.id, progress: -1).count diff --git a/app/models/tutorial.rb b/app/models/tutorial.rb index 8fd72418a..31f281d4f 100644 --- a/app/models/tutorial.rb +++ b/app/models/tutorial.rb @@ -1,7 +1,5 @@ # Tutorial model class Tutorial < ApplicationRecord - require "csv" - belongs_to :lecture, touch: true has_many :tutor_tutorial_joins, dependent: :destroy diff --git a/app/models/voucher/voucher.rb b/app/models/voucher/voucher.rb index ccd1ac2da..04a03a996 100644 --- a/app/models/voucher/voucher.rb +++ b/app/models/voucher/voucher.rb @@ -20,7 +20,7 @@ class Voucher < ApplicationRecord DEFAULT_EXPIRATION_DAYS = 3 ROLE_HASH = { tutor: 0, editor: 1, teacher: 2, speaker: 3 }.freeze - enum role: ROLE_HASH + enum :role, ROLE_HASH validates :role, presence: true belongs_to :lecture, touch: true diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 000000000..40330c0ff --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup index 2cc479483..f73363809 100755 --- a/bin/setup +++ b/bin/setup @@ -1,8 +1,8 @@ #!/usr/bin/env ruby require "fileutils" -# path to your application root. APP_ROOT = File.expand_path("..", __dir__) +APP_NAME = "mampf" def system!(*args) system(*args, exception: true) @@ -17,9 +17,6 @@ FileUtils.chdir APP_ROOT do system! "gem install bundler --conservative" system("bundle check") || system!("bundle install") - # Install JavaScript dependencies - system! 'bin/yarn' - # puts "\n== Copying sample files ==" # unless File.exist?("config/database.yml") # FileUtils.cp "config/database.yml.sample", "config/database.yml" @@ -33,4 +30,8 @@ FileUtils.chdir APP_ROOT do puts "\n== Restarting application server ==" system! "bin/rails restart" + + # puts "\n== Configuring puma-dev ==" + # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" + # system "curl -Is https://#{APP_NAME}.test/up | head -n 1" end diff --git a/config/application.rb b/config/application.rb index de5fae844..be78e6e80 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,8 +9,7 @@ module Mampf class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults(7.1) - config.autoloader = :zeitwerk + config.load_defaults(7.2) # Autoload subfolders of modules (recursively) # https://stackoverflow.com/a/4794775/ diff --git a/config/environments/development.rb b/config/environments/development.rb index c6529aa9d..8c1e9f7ca 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -83,4 +83,11 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + # + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true + + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + # config.generators.apply_rubocop_autocorrect_after_generate! end diff --git a/config/environments/docker_development.rb b/config/environments/docker_development.rb index f2be5f19d..f01c6f2e5 100644 --- a/config/environments/docker_development.rb +++ b/config/environments/docker_development.rb @@ -90,4 +90,10 @@ config.web_console.allowed_ips = Socket.ip_address_list.reduce([]) do |res, addrinfo| addrinfo.ipv4? ? res << IPAddr.new(addrinfo.ip_address).mask(24) : res end + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true + + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + # config.generators.apply_rubocop_autocorrect_after_generate! end diff --git a/config/environments/production.rb b/config/environments/production.rb index 7f0f4cec4..0fdff9720 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -17,7 +17,7 @@ # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], # config/master.key, or an environment key such as config/credentials/production.key. # This key is used to decrypt credentials (and other encrypted files). - config.require_master_key = true + # config.require_master_key = true # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? @@ -29,6 +29,9 @@ # Do not fall back to assets pipeline if a precompiled asset is missed. config.assets.compile = false + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX @@ -39,6 +42,21 @@ # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = Logger::Formatter.new + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = "wss://example.com/cable" + # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } + if ENV["RAILS_LOG_TO_STDOUT"].present? config.logger = ActiveSupport::Logger.new($stdout) .tap { |logger| logger.formatter = config.log_formatter } @@ -83,4 +101,15 @@ production_name = ENV.fetch("PRODUCTION_NAME", nil) Rails.logger.info("PRODUCTION_NAME: #{production_name}") end + + # See https://github.com/rails/rails/issues/52728 + config.active_record.attributes_for_inspect = :all + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 6031f4365..e2c369e87 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/integer/time" + # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped diff --git a/config/puma.rb b/config/puma.rb index 06209aa8b..03c166f4c 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,25 +1,34 @@ -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers: a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum; this matches the default thread size of Active Record. +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. -max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } -threads min_threads_count, max_threads_count - -# Specifies the `worker_timeout` threshold that Puma will use to wait before -# terminating a worker in development environments. -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. +# +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# to prioritize throughput over latency. +# +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. +# +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. +# +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) +threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. port ENV.fetch("PORT", 3000) -# Specifies the `environment` that Puma will run in. -environment ENV.fetch("RAILS_ENV") { "development" } - -# Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } - -# Allow puma to be restarted by `rails restart` command. +# Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart + +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +pidfile ENV["PIDFILE"] if ENV["PIDFILE"] diff --git a/db/interactions_schema.rb b/db/interactions_schema.rb index 4440cb9b3..6d1f84187 100644 --- a/db/interactions_schema.rb +++ b/db/interactions_schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2020_06_13_112557) do +ActiveRecord::Schema[7.2].define(version: 2020_06_13_112557) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -43,5 +43,4 @@ t.text "input" t.integer "remark_id" end - end diff --git a/db/schema.rb b/db/schema.rb index 0a6d204ba..5bf3c6785 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_09_21_221000) do +ActiveRecord::Schema[7.2].define(version: 2024_09_21_221000) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" diff --git a/docker/development/Dockerfile b/docker/development/Dockerfile index 681e5826f..3e9fd643c 100644 --- a/docker/development/Dockerfile +++ b/docker/development/Dockerfile @@ -11,13 +11,13 @@ RUN cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" . # Now build the actual MaMpf application # https://hub.docker.com/_/ruby/ -FROM ruby:3.1.4-bullseye +FROM ruby:3.3.7-bullseye EXPOSE 3000 EXPOSE 9394 # use "--login" option, so that .bashrc is sourced in new shells -SHELL ["/bin/bash", "--login", "-c"] +SHELL ["/bin/bash", "--login", "-c"] # Install Node.js # https://github.com/nodesource/distributions/issues/1583#issuecomment-1597489401 @@ -74,7 +74,7 @@ RUN if [ "$IN_CI_CD" = "true" ]; then \ echo "Running yarn install"; \ yarn install --production --frozen-lockfile; \ fi - + # Precompile assets in CI/CD # (See the production Dockerfile for an explanation of the dummy env file) COPY . /usr/src/app/ diff --git a/docker/production/Dockerfile b/docker/production/Dockerfile index 92d8d67c3..bd1362dea 100644 --- a/docker/production/Dockerfile +++ b/docker/production/Dockerfile @@ -7,7 +7,7 @@ RUN GOOS=js GOARCH=wasm go build -o pdfcomprezzor.wasm RUN cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" . # Now build the actual mampf application -FROM ruby:3.1.4 +FROM ruby:3.3.7-bullseye ENV RAILS_ENV=production @@ -17,7 +17,7 @@ EXPOSE 9394 ENTRYPOINT ["/usr/src/app/docker/entrypoint-worker.sh"] # use "--login" option, so that .bashrc is sourced in new shells -SHELL ["/bin/bash", "--login", "-c"] +SHELL ["/bin/bash", "--login", "-c"] # Install Node.js # https://github.com/nodesource/distributions/issues/1583#issuecomment-1597489401 @@ -106,7 +106,7 @@ COPY --chown=app:app . /usr/src/app # file and source it here in the Dockerfile just to have the precompile task run # successfully (this task doesn't even rely on the actual values, so despite # being a hack, it should be fine). -# +# # I've written down more details in this question on StackOverflow: # https://stackoverflow.com/q/78098380/ COPY ./docker/production/docker.env ./docker-dummy.env diff --git a/lib/clients/erdbeere_client.rb b/lib/clients/erdbeere_client.rb index 37c2edead..c02f04dc4 100644 --- a/lib/clients/erdbeere_client.rb +++ b/lib/clients/erdbeere_client.rb @@ -2,12 +2,11 @@ module Clients class ErdbeereClient Response = Struct.new(:status, :body) - def self.get(path, params: nil, headers: {}, &block) + def self.get(path, params: nil, headers: {}, &) headers = headers.dup headers["Host"] = "localhost" if Rails.env.docker_development? - ERDBEERE_CONNECTION.get(path, params, headers, &block) + ERDBEERE_CONNECTION.get(path, params, headers, &) rescue Faraday::Error => e - pp("---------------------------------") Rails.logger.error("ErdbeereClient.get error: #{e.message}") Response.new(500, { error: e.message }.to_json) end diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html new file mode 100644 index 000000000..7cf1e168e --- /dev/null +++ b/public/406-unsupported-browser.html @@ -0,0 +1,66 @@ + + +
+Please upgrade your browser to continue.
+