The server cannot process the request due to a client error. Please check the request and try again. If you're the application owner check the logs for more information.
+diff --git a/Gemfile b/Gemfile index ac428b72..8a6513fd 100644 --- a/Gemfile +++ b/Gemfile @@ -32,7 +32,9 @@ gem 'importmap-rails' # Build JSON APIs with ease [https://github.com/rails/jbuilder] gem 'jbuilder' -gem 'mitlibraries-theme', git: 'https://github.com/mitlibraries/mitlibraries-theme', tag: 'v1.4' +gem 'mitlibraries-theme', + git: 'https://github.com/mitlibraries/mitlibraries-theme', + tag: 'v1.5' # Use OmniAuth as Touchstone middleware and include the OIDC strategy and CSRF protection gems gem 'omniauth' @@ -52,7 +54,7 @@ gem 'puma', '>= 5.0' gem 'scout_apm' # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem 'rails', '~> 7.2.2' +gem 'rails', '~> 8.1.0' # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem 'sprockets-rails' @@ -87,7 +89,7 @@ gem 'stringex' # gem "image_processing", "~> 1.2" group :production do - gem 'connection_pool', '< 3' + gem 'connection_pool' # Use postgres as the database for Active Record gem 'pg' end @@ -107,7 +109,7 @@ end group :development do # Add annotations to model, test, fixtures when run - gem 'annotate' + gem 'annotaterb' # RuboCop is a Ruby static code analyzer (a.k.a. linter) and code formatter. gem 'rubocop', require: false @@ -129,7 +131,7 @@ group :test do # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] gem 'capybara' gem 'climate_control' - gem 'minitest', '< 6' + gem 'minitest' gem 'mocha' gem 'selenium-webdriver' gem 'simplecov' diff --git a/Gemfile.lock b/Gemfile.lock index a7af478b..3067fd64 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,88 +1,89 @@ GIT remote: https://github.com/mitlibraries/mitlibraries-theme - revision: ba5bdc9840ef817ba0b92e522b92da3f52669fc3 - tag: v1.4 + revision: 135390daff870937212f1d9020abb6aea53c87d9 + tag: v1.5 specs: - mitlibraries-theme (1.0.2) - rails (>= 6, < 8) + mitlibraries-theme (1.1.0) + rails (>= 6, < 9) sassc-rails (~> 2) GEM remote: https://rubygems.org/ specs: - actioncable (7.2.3.2) - actionpack (= 7.2.3.2) - activesupport (= 7.2.3.2) + action_text-trix (2.1.19) + railties + actioncable (8.1.3.1) + actionpack (= 8.1.3.1) + activesupport (= 8.1.3.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.2.3.2) - actionpack (= 7.2.3.2) - activejob (= 7.2.3.2) - activerecord (= 7.2.3.2) - activestorage (= 7.2.3.2) - activesupport (= 7.2.3.2) + actionmailbox (8.1.3.1) + actionpack (= 8.1.3.1) + activejob (= 8.1.3.1) + activerecord (= 8.1.3.1) + activestorage (= 8.1.3.1) + activesupport (= 8.1.3.1) mail (>= 2.8.0) - actionmailer (7.2.3.2) - actionpack (= 7.2.3.2) - actionview (= 7.2.3.2) - activejob (= 7.2.3.2) - activesupport (= 7.2.3.2) + actionmailer (8.1.3.1) + actionpack (= 8.1.3.1) + actionview (= 8.1.3.1) + activejob (= 8.1.3.1) + activesupport (= 8.1.3.1) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.2.3.2) - actionview (= 7.2.3.2) - activesupport (= 7.2.3.2) - cgi + actionpack (8.1.3.1) + actionview (= 8.1.3.1) + activesupport (= 8.1.3.1) nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.3) + rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (7.2.3.2) - actionpack (= 7.2.3.2) - activerecord (= 7.2.3.2) - activestorage (= 7.2.3.2) - activesupport (= 7.2.3.2) + actiontext (8.1.3.1) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.3.1) + activerecord (= 8.1.3.1) + activestorage (= 8.1.3.1) + activesupport (= 8.1.3.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.2.3.2) - activesupport (= 7.2.3.2) + actionview (8.1.3.1) + activesupport (= 8.1.3.1) builder (~> 3.1) - cgi erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.2.3.2) - activesupport (= 7.2.3.2) + activejob (8.1.3.1) + activesupport (= 8.1.3.1) globalid (>= 0.3.6) - activemodel (7.2.3.2) - activesupport (= 7.2.3.2) - activerecord (7.2.3.2) - activemodel (= 7.2.3.2) - activesupport (= 7.2.3.2) + activemodel (8.1.3.1) + activesupport (= 8.1.3.1) + activerecord (8.1.3.1) + activemodel (= 8.1.3.1) + activesupport (= 8.1.3.1) timeout (>= 0.4.0) - activestorage (7.2.3.2) - actionpack (= 7.2.3.2) - activejob (= 7.2.3.2) - activerecord (= 7.2.3.2) - activesupport (= 7.2.3.2) + activestorage (8.1.3.1) + actionpack (= 8.1.3.1) + activejob (= 8.1.3.1) + activerecord (= 8.1.3.1) + activesupport (= 8.1.3.1) marcel (~> 1.0) - activesupport (7.2.3.2) + activesupport (8.1.3.1) base64 - benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json logger (>= 1.4.2) - minitest (>= 5.1, < 6) + minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) addressable (2.9.0) public_suffix (>= 2.0.2, < 8.0) administrate (1.0.0) @@ -91,9 +92,9 @@ GEM activerecord (>= 6.0, < 9.0) kaminari (~> 1.2.2) aes_key_wrap (1.1.0) - annotate (3.2.0) - activerecord (>= 3.2, < 8.0) - rake (>= 10.4, < 14.0) + annotaterb (4.24.0) + activerecord (>= 6.0.0) + activesupport (>= 6.0.0) ast (2.4.3) attr_required (1.0.2) awesome_print (1.9.2) @@ -103,7 +104,6 @@ GEM ostruct base64 (0.3.0) bcrypt (3.1.22) - benchmark (0.5.0) bigdecimal (4.1.2) bindata (3.0.0) bindex (0.8.1) @@ -120,10 +120,9 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - cgi (0.5.2) climate_control (1.2.0) concurrent-ruby (1.3.8) - connection_pool (2.5.5) + connection_pool (3.0.2) crack (1.0.1) bigdecimal rexml @@ -139,14 +138,13 @@ GEM railties (>= 7.0) responders warden (~> 1.2.3) - docile (1.4.1) domain_name (0.6.20240107) dotenv (3.2.0) dotenv-rails (3.2.0) dotenv (= 3.2.0) railties (>= 6.1) drb (2.2.3) - erb (6.0.6) + erb (6.0.7) erubi (1.13.1) faraday (2.14.3) faraday-net_http (>= 2.0, < 3.5) @@ -230,7 +228,9 @@ GEM marcel (1.2.1) matrix (0.4.3) mini_mime (1.1.5) - minitest (5.27.0) + minitest (6.0.6) + drb (~> 2.0) + prism (~> 1.5) mocha (3.1.0) ruby2_keywords (>= 0.0.5) msgpack (1.8.4) @@ -332,20 +332,20 @@ GEM rack (>= 1.3) rackup (2.3.1) rack (>= 3) - rails (7.2.3.2) - actioncable (= 7.2.3.2) - actionmailbox (= 7.2.3.2) - actionmailer (= 7.2.3.2) - actionpack (= 7.2.3.2) - actiontext (= 7.2.3.2) - actionview (= 7.2.3.2) - activejob (= 7.2.3.2) - activemodel (= 7.2.3.2) - activerecord (= 7.2.3.2) - activestorage (= 7.2.3.2) - activesupport (= 7.2.3.2) + rails (8.1.3.1) + actioncable (= 8.1.3.1) + actionmailbox (= 8.1.3.1) + actionmailer (= 8.1.3.1) + actionpack (= 8.1.3.1) + actiontext (= 8.1.3.1) + actionview (= 8.1.3.1) + activejob (= 8.1.3.1) + activemodel (= 8.1.3.1) + activerecord (= 8.1.3.1) + activestorage (= 8.1.3.1) + activesupport (= 8.1.3.1) bundler (>= 1.15.0) - railties (= 7.2.3.2) + railties (= 8.1.3.1) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest @@ -353,10 +353,9 @@ GEM rails-html-sanitizer (1.7.1) loofah (~> 2.25, >= 2.25.2) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.2.3.2) - actionpack (= 7.2.3.2) - activesupport (= 7.2.3.2) - cgi + railties (8.1.3.1) + actionpack (= 8.1.3.1) + activesupport (= 8.1.3.1) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -435,20 +434,15 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 4.0) websocket (~> 1.0) - sentry-rails (6.6.2) + sentry-rails (6.7.0) railties (>= 5.2.0) - sentry-ruby (~> 6.6.2) - sentry-ruby (6.6.2) + sentry-ruby (~> 6.7.0) + sentry-ruby (6.7.0) bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) logger - simplecov (0.22.0) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.13.2) + simplecov (1.0.3) simplecov-lcov (0.9.0) - simplecov_json_formatter (0.1.4) sprockets (4.2.2) concurrent-ruby (~> 1.0) logger @@ -493,11 +487,10 @@ GEM vcr (6.4.0) warden (1.2.9) rack (>= 2.0.9) - web-console (4.2.1) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) + web-console (4.3.0) + actionview (>= 8.0.0) bindex (>= 0.4.0) - railties (>= 6.0.0) + railties (>= 8.0.0) webfinger (2.1.3) activesupport faraday (~> 2.0) @@ -531,14 +524,14 @@ PLATFORMS DEPENDENCIES administrate (~> 1.0.0) - annotate + annotaterb awesome_print barnes bootsnap cancancan capybara climate_control - connection_pool (< 3) + connection_pool csv debug devise @@ -547,7 +540,7 @@ DEPENDENCIES http importmap-rails jbuilder - minitest (< 6) + minitest mitlibraries-theme! mocha omniauth @@ -558,7 +551,7 @@ DEPENDENCIES pg puma (>= 5.0) rack-cors - rails (~> 7.2.2) + rails (~> 8.1.0) rubocop rubocop-capybara rubocop-graphql diff --git a/Makefile b/Makefile index ca21f571..37d4ebd3 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ coverage: test # Run tests and open coverage report in default web browser ####################### annotate: # update Rails models documentation header - bundle exec annotate --models + bundle exec annotaterb models docserver: # runs local documentation server rm -rf .yardoc # Clears cache as it's sketchy af diff --git a/README.md b/README.md index dad8ecfc..f751e8bf 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,12 @@ apps; it should never be manually set or overridden in any environment. [Pattern Detection and Enhancement](docs/explanation/pattern_detection_and_enhancement.md) +### Annotations + +`make annotate` will ensure that models have current internal documentation. This uses the [annotaterb](https://rubygems.org/gems/annotaterb) gem. + +Other options provided by this gem can be explored via `bundle exec annotaterb help`. + ### Reference `make docserver` will start a `yard` server using the RDoc comments from the codebase. RDoc in this application is a work-in-progress and should improve over time. As of this writing, the index page generated contains broken links to our markdown documentation, but they "files" navigation displays them properly. diff --git a/app/models/categorization.rb b/app/models/categorization.rb index e5d9d1f8..9d8e268f 100644 --- a/app/models/categorization.rb +++ b/app/models/categorization.rb @@ -13,12 +13,23 @@ # Table name: categorizations # # id :integer not null, primary key -# category_id :integer not null -# term_id :integer not null # confidence :float # detector_version :string # created_at :datetime not null # updated_at :datetime not null +# category_id :integer not null +# term_id :integer not null +# +# Indexes +# +# idx_on_term_id_category_id_confidence_detector_vers_2ed1c1cbf9 (term_id,category_id,confidence,detector_version) UNIQUE +# index_categorizations_on_category_id (category_id) +# index_categorizations_on_term_id (term_id) +# +# Foreign Keys +# +# category_id (category_id => categories.id) +# term_id (term_id => terms.id) # class Categorization < ApplicationRecord belongs_to :term diff --git a/app/models/category.rb b/app/models/category.rb index 4b389f51..fdb4b428 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -5,11 +5,15 @@ # Table name: categories # # id :integer not null, primary key -# name :string # description :text +# name :string # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# index_categories_on_name (name) UNIQUE +# class Category < ApplicationRecord has_many :detector_categories, dependent: :destroy has_many :detectors, through: :detector_categories diff --git a/app/models/confirmation.rb b/app/models/confirmation.rb index ce937dc8..2f26e554 100644 --- a/app/models/confirmation.rb +++ b/app/models/confirmation.rb @@ -14,11 +14,25 @@ # Table name: confirmations # # id :integer not null, primary key -# user_id :integer not null -# term_id :integer not null -# category_id :integer not null # created_at :datetime not null # updated_at :datetime not null +# category_id :integer not null +# term_id :integer not null +# user_id :integer not null +# +# Indexes +# +# index_confirmations_on_category_id (category_id) +# index_confirmations_on_term_id (term_id) +# index_confirmations_on_term_id_and_user_id (term_id,user_id) UNIQUE +# index_confirmations_on_user_id (user_id) +# index_confirmations_on_user_id_and_term_id (user_id,term_id) UNIQUE +# +# Foreign Keys +# +# category_id (category_id => categories.id) +# term_id (term_id => terms.id) +# user_id (user_id => users.id) # class Confirmation < ApplicationRecord belongs_to :user diff --git a/app/models/detection.rb b/app/models/detection.rb index 7729e28b..b1430619 100644 --- a/app/models/detection.rb +++ b/app/models/detection.rb @@ -13,11 +13,23 @@ # Table name: detections # # id :integer not null, primary key -# term_id :integer not null -# detector_id :integer not null # detector_version :string # created_at :datetime not null # updated_at :datetime not null +# detector_id :integer not null +# term_id :integer not null +# +# Indexes +# +# idx_on_detector_id_term_id_detector_version_2afa383b1f (detector_id,term_id,detector_version) UNIQUE +# idx_on_term_id_detector_id_detector_version_03898e846f (term_id,detector_id,detector_version) UNIQUE +# index_detections_on_detector_id (detector_id) +# index_detections_on_term_id (term_id) +# +# Foreign Keys +# +# detector_id (detector_id => detectors.id) +# term_id (term_id => terms.id) # class Detection < ApplicationRecord belongs_to :term diff --git a/app/models/detector.rb b/app/models/detector.rb index 3a0c9297..4b4dd0f1 100644 --- a/app/models/detector.rb +++ b/app/models/detector.rb @@ -19,6 +19,10 @@ # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# index_detectors_on_name (name) UNIQUE +# class Detector < ApplicationRecord has_many :detector_categories, dependent: :destroy has_many :categories, through: :detector_categories diff --git a/app/models/detector_category.rb b/app/models/detector_category.rb index d322332e..ab6ebdfd 100644 --- a/app/models/detector_category.rb +++ b/app/models/detector_category.rb @@ -5,11 +5,23 @@ # Table name: detector_categories # # id :integer not null, primary key -# detector_id :integer not null -# category_id :integer not null # confidence :float # created_at :datetime not null # updated_at :datetime not null +# category_id :integer not null +# detector_id :integer not null +# +# Indexes +# +# index_detector_categories_on_category_id (category_id) +# index_detector_categories_on_category_id_and_detector_id (category_id,detector_id) +# index_detector_categories_on_detector_id (detector_id) +# index_detector_categories_on_detector_id_and_category_id (detector_id,category_id) +# +# Foreign Keys +# +# category_id (category_id => categories.id) +# detector_id (detector_id => detectors.id) # class DetectorCategory < ApplicationRecord belongs_to :category diff --git a/app/models/fingerprint.rb b/app/models/fingerprint.rb index db69eec7..fca3fa40 100644 --- a/app/models/fingerprint.rb +++ b/app/models/fingerprint.rb @@ -9,6 +9,10 @@ # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# unique_fingerprint (value) UNIQUE +# class Fingerprint < ApplicationRecord has_many :terms, dependent: :nullify diff --git a/app/models/journal.rb b/app/models/journal.rb index e4b89f34..df744040 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -5,11 +5,15 @@ # Table name: journals # # id :integer not null, primary key -# name :string # additional_info :json +# name :string # created_at :datetime not null # updated_at :datetime not null # +# Indexes +# +# index_journals_on_name (name) +# # Journal is the list of academic journals which are known to TACOS. This list of records is referred to by the # Detector::Journal model in order to determine whether a given term matches a known journal. The names of these diff --git a/app/models/metrics/algorithms.rb b/app/models/metrics/algorithms.rb index 27c7f292..14e3970e 100644 --- a/app/models/metrics/algorithms.rb +++ b/app/models/metrics/algorithms.rb @@ -5,19 +5,19 @@ # Table name: metrics_algorithms # # id :integer not null, primary key -# month :date +# barcode :integer +# citation :integer # doi :integer -# issn :integer # isbn :integer +# issn :integer +# journal_exact :integer +# lcsh :integer +# month :date # pmid :integer +# suggested_resource_exact :integer # unmatched :integer # created_at :datetime not null # updated_at :datetime not null -# journal_exact :integer -# suggested_resource_exact :integer -# lcsh :integer -# citation :integer -# barcode :integer # module Metrics # Algorithms aggregates statistics for matches for all SearchEvents diff --git a/app/models/search_event.rb b/app/models/search_event.rb index 7042b8f5..6ea43d2a 100644 --- a/app/models/search_event.rb +++ b/app/models/search_event.rb @@ -5,10 +5,15 @@ # Table name: search_events # # id :integer not null, primary key -# term_id :integer # source :string # created_at :datetime not null # updated_at :datetime not null +# term_id :integer +# +# Indexes +# +# index_search_events_on_source (source) +# index_search_events_on_term_id (term_id) # # SearchEvent represents an instance of a logged search Term diff --git a/app/models/suggested_pattern.rb b/app/models/suggested_pattern.rb index d5af8703..d17022d9 100644 --- a/app/models/suggested_pattern.rb +++ b/app/models/suggested_pattern.rb @@ -5,14 +5,24 @@ # Table name: suggested_patterns # # id :integer not null, primary key -# title :string not null -# url :string not null +# confidence :float default(0.9) # pattern :string not null # shortcode :string not null +# title :string not null +# url :string not null # created_at :datetime not null # updated_at :datetime not null # category_id :integer -# confidence :float default(0.9) +# +# Indexes +# +# index_suggested_patterns_on_category_id (category_id) +# index_suggested_patterns_on_pattern (pattern) UNIQUE +# index_suggested_patterns_on_shortcode (shortcode) UNIQUE +# +# Foreign Keys +# +# category_id (category_id => categories.id) ON DELETE => nullify # class SuggestedPattern < ApplicationRecord validates :title, presence: true diff --git a/app/models/suggested_resource.rb b/app/models/suggested_resource.rb index 51d107bd..b547bcf6 100644 --- a/app/models/suggested_resource.rb +++ b/app/models/suggested_resource.rb @@ -5,12 +5,20 @@ # Table name: suggested_resources # # id :integer not null, primary key +# confidence :float default(0.9) # title :string # url :string # created_at :datetime not null # updated_at :datetime not null # category_id :integer -# confidence :float default(0.9) +# +# Indexes +# +# index_suggested_resources_on_category_id (category_id) +# +# Foreign Keys +# +# category_id (category_id => categories.id) ON DELETE => nullify # class SuggestedResource < ApplicationRecord has_many :terms, dependent: :nullify diff --git a/app/models/term.rb b/app/models/term.rb index 23e20d6c..7ff13408 100644 --- a/app/models/term.rb +++ b/app/models/term.rb @@ -8,13 +8,25 @@ # Table name: terms # # id :integer not null, primary key +# flag :boolean +# label :boolean # phrase :string # created_at :datetime not null # updated_at :datetime not null -# flag :boolean # fingerprint_id :integer # suggested_resource_id :integer # +# Indexes +# +# index_terms_on_fingerprint_id (fingerprint_id) +# index_terms_on_suggested_resource_id (suggested_resource_id) +# unique_phrase (phrase) UNIQUE +# +# Foreign Keys +# +# fingerprint_id (fingerprint_id => fingerprints.id) +# suggested_resource_id (suggested_resource_id => suggested_resources.id) ON DELETE => nullify +# class Term < ApplicationRecord has_many :search_events, dependent: :destroy has_many :detections, dependent: :destroy diff --git a/app/models/user.rb b/app/models/user.rb index b453ed72..0cb3bf9d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,11 +5,16 @@ # Table name: users # # id :integer not null, primary key -# uid :string not null +# admin :boolean default(FALSE) # email :string not null +# uid :string not null # created_at :datetime not null # updated_at :datetime not null -# admin :boolean default(FALSE) +# +# Indexes +# +# index_users_on_email (email) UNIQUE +# index_users_on_uid (uid) UNIQUE # class User < ApplicationRecord has_many :confirmations, dependent: :destroy diff --git a/bin/ci b/bin/ci new file mode 100755 index 00000000..4137ad5b --- /dev/null +++ b/bin/ci @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "active_support/continuous_integration" + +CI = ActiveSupport::ContinuousIntegration +require_relative "../config/ci.rb" diff --git a/bin/dev b/bin/dev new file mode 100755 index 00000000..5f91c205 --- /dev/null +++ b/bin/dev @@ -0,0 +1,2 @@ +#!/usr/bin/env ruby +exec "./bin/rails", "server", *ARGV diff --git a/bin/rubocop b/bin/rubocop index 40330c0f..5a205047 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -2,7 +2,7 @@ require "rubygems" require "bundler/setup" -# explicit rubocop config increases performance slightly while avoiding config confusion. +# 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 65d3106a..81be011e 100755 --- a/bin/setup +++ b/bin/setup @@ -2,7 +2,6 @@ require "fileutils" APP_ROOT = File.expand_path("..", __dir__) -APP_NAME = "tacos" def system!(*args) system(*args, exception: true) @@ -14,7 +13,6 @@ FileUtils.chdir APP_ROOT do # Add necessary setup steps to this file. puts "== Installing dependencies ==" - system! "gem install bundler --conservative" system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" @@ -24,14 +22,14 @@ FileUtils.chdir APP_ROOT do puts "\n== Preparing database ==" system! "bin/rails db:prepare" + system! "bin/rails db:reset" if ARGV.include?("--reset") puts "\n== Removing old logs and tempfiles ==" system! "bin/rails log:clear tmp:clear" - 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" + unless ARGV.include?("--skip-server") + puts "\n== Starting development server ==" + STDOUT.flush # flush the output before exec(2) so that it displays + exec "bin/dev" + end end diff --git a/config/application.rb b/config/application.rb index 324bbac6..8428ab02 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,7 @@ module Tacos class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.2 + config.load_defaults 8.1 # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. diff --git a/config/ci.rb b/config/ci.rb new file mode 100644 index 00000000..9014db21 --- /dev/null +++ b/config/ci.rb @@ -0,0 +1,22 @@ +# Run using bin/ci + +CI.run do + step "Setup", "bin/setup --skip-server" + + step "Style: Ruby", "bin/rubocop" + + # step "Security: Importmap vulnerability audit", "bin/importmap audit" + step "Tests: Rails", "bin/rails test" + step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant" + + # Optional: Run system tests + # step "Tests: System", "bin/rails test:system" + + # Optional: set a green GitHub commit status to unblock PR merge. + # Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`. + # if success? + # step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff" + # else + # failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again." + # end +end diff --git a/config/environments/development.rb b/config/environments/development.rb index 45332dc0..09ebac9a 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -3,9 +3,7 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded any time - # it changes. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. + # Make code changes take effect immediately without server restart. config.enable_reloading = true # Do not eager load code on boot. @@ -17,52 +15,48 @@ # Enable server timing. config.server_timing = true - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. + # Enable/disable Action Controller caching. By default Action Controller caching is disabled. + # Run rails dev:cache to toggle Action Controller caching. if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.action_controller.enable_fragment_cache_logging = true - - config.cache_store = :memory_store - config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } + config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false - - config.cache_store = :null_store end + # Change to :null_store to avoid any caching. + config.cache_store = :memory_store + # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false - # Disable caching for Action Mailer templates even if Action Controller - # caching is enabled. + # Make template changes take effect immediately. config.action_mailer.perform_caching = false + # Set localhost to be used by links generated in mailer templates. config.action_mailer.default_url_options = { host: "localhost", port: 3000 } # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Append comments with runtime information tags to SQL queries in logs. + config.active_record.query_log_tags_enabled = true + # Highlight code that enqueued background job in logs. config.active_job.verbose_enqueue_logs = true - # Suppress logger output for asset requests. - config.assets.quiet = true + # Highlight code that triggered redirect in logs. + config.action_dispatch.verbose_redirect_logs = true # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true diff --git a/config/environments/production.rb b/config/environments/production.rb index b1771c62..b84de475 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -6,25 +6,20 @@ # Code is not reloaded between requests. config.enable_reloading = false - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. + # Eager load code on boot for better performance and memory savings (ignored by Rake tasks). config.eager_load = true - # Full error reports are disabled and caching is turned on. + # Full error reports are disabled. config.consider_all_requests_local = false - config.action_controller.perform_caching = true - # 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 + # Turn on fragment caching in view templates. + config.action_controller.perform_caching = true # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. config.public_file_server.enabled = true - # Compress CSS using a preprocessor. - # config.assets.css_compressor = :sass + # Cache assets for far-future expiry since they are all digest stamped. + config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" } # Do not fall back to assets pipeline if a precompiled asset is missed. config.assets.compile = false @@ -32,21 +27,11 @@ # 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 - # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local - # 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 + config.assume_ssl = true # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true @@ -59,36 +44,44 @@ .tap { |logger| logger.formatter = ::Logger::Formatter.new } .then { |logger| ActiveSupport::TaggedLogging.new(logger) } - # Prepend all log lines with the following tags. + # Log to STDOUT with the current request id as a default log tag. config.log_tags = [ :request_id ] - # "info" includes generic and useful information about system operation, but avoids logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). If you - # want to log everything, set the level to "debug". + # Change to "debug" to log everything (including potentially personally-identifiable information!). config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") - # Use a different cache store in production. + # Prevent health checks from clogging up the logs. + config.silence_healthcheck_path = "/up" + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Replace the default in-process memory cache store with a durable alternative. # config.cache_store = :mem_cache_store - # Use a real queuing backend for Active Job (and separate queues per environment). + # Replace the default in-process and non-durable queuing backend for Active Job. # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "tacos_production" - - # Disable caching for Action Mailer templates even if Action Controller - # caching is enabled. - config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "example.com" } + + # Specify outgoing SMTP server. Remember to add smtp/* credentials via bin/rails credentials:edit. + # config.action_mailer.smtp_settings = { + # user_name: Rails.application.credentials.dig(:smtp, :user_name), + # password: Rails.application.credentials.dig(:smtp, :password), + # address: "smtp.example.com", + # port: 587, + # authentication: :plain + # } + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Don't log any deprecations. - config.active_support.report_deprecations = false - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false @@ -100,6 +93,7 @@ # "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 0c616a1b..c2095b11 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,5 +1,3 @@ -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 @@ -17,12 +15,11 @@ # loading is working properly before deploying your code. config.eager_load = ENV["CI"].present? - # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" } + # Configure public file server for tests with cache-control for performance. + config.public_file_server.headers = { "cache-control" => "public, max-age=3600" } - # Show full error reports and disable caching. + # Show full error reports. config.consider_all_requests_local = true - config.action_controller.perform_caching = false config.cache_store = :null_store # Render exception templates for rescuable exceptions and raise for other exceptions. @@ -34,28 +31,17 @@ # Store uploaded files on the local file system in a temporary directory. config.active_storage.service = :test - # Disable caching for Action Mailer templates even if Action Controller - # caching is enabled. - config.action_mailer.perform_caching = false - # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Unlike controllers, the mailer instance doesn't have any context about the - # incoming request so you'll need to provide the :host parameter yourself. - config.action_mailer.default_url_options = { host: "www.example.com" } + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "example.com" } # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index bd5bcd2b..48732442 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -5,8 +5,3 @@ # Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path - -# Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in the app/assets -# folder are already added. -# Rails.application.config.assets.precompile += %w[ admin.js admin.css ] diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index b3076b38..d51d7139 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -20,6 +20,10 @@ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } # config.content_security_policy_nonce_directives = %w(script-src style-src) # +# # Automatically add `nonce` to `javascript_tag`, `javascript_include_tag`, and `stylesheet_link_tag` +# # if the corresponding directives are specified in `content_security_policy_nonce_directives`. +# # config.content_security_policy_nonce_auto = true +# # # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true # end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 9b8100bd..c0b717f7 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -4,5 +4,5 @@ # Use this to limit dissemination of sensitive information. # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. Rails.application.config.filter_parameters += [ - :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp + :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc ] diff --git a/config/puma.rb b/config/puma.rb index 7f170318..e3dcaf8b 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,13 +1,18 @@ # 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. - +# # Puma starts a configurable number of processes (workers) and each process # serves each request in a thread from an internal thread pool. # +# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You +# should only set this value when you want to run 2 or more workers. The +# default is already 1. You can set it to `auto` to automatically start a worker +# for each available processor. +# # 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. +# 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 @@ -37,6 +42,9 @@ Barnes.start # Must have enabled worker mode for this to block to be called end +# Run the Solid Queue supervisor inside of Puma for single-server deployments. +plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] + # 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/config/routes.rb b/config/routes.rb index 55adb25c..d5f7b3d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,10 @@ Rails.application.routes.draw do + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. + # Can be used by load balancers and uptime monitors to verify that the app is live. + get 'up' => 'rails/health#show', as: :rails_health_check + devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }, only: [:omniauth_callbacks] devise_scope :user do delete '/users/sign_out', to: 'devise/sessions#destroy', as: :destroy_user_session @@ -25,12 +31,6 @@ post '/graphql', to: 'graphql#execute' - # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - - # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. - # Can be used by load balancers and uptime monitors to verify that the app is live. - get 'up' => 'rails/health#show', as: :rails_health_check - get 'playground', to: 'static#playground' get '/report', to: 'report#index' get '/report/algorithm_metrics', to: 'report#algorithm_metrics' diff --git a/public/400.html b/public/400.html new file mode 100644 index 00000000..640de033 --- /dev/null +++ b/public/400.html @@ -0,0 +1,135 @@ + + + + +
+ +The server cannot process the request due to a client error. Please check the request and try again. If you're the application owner check the logs for more information.
+You may have mistyped the address or the page may have moved.
-If you are the application owner check the logs for more information.
-The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved. If you're the application owner check the logs for more information.
+Please upgrade your browser to continue.
-Your browser is not supported.
Please upgrade your browser to continue.
Maybe you tried to change something you didn't have access to.
-If you are the application owner check the logs for more information.
-The change you wanted was rejected. Maybe you tried to change something you didn't have access to. If you're the application owner check the logs for more information.
+If you are the application owner check the logs for more information.
-We're sorry, but something went wrong.
If you're the application owner check the logs for more information.