Skip to content

Commit

Permalink
Rails 7.1 (Attempt 2) (#1359)
Browse files Browse the repository at this point in the history
* Bump Rails to 7.1

* Remove location_id from split fixtures

* Begin working through deprecations and activerecord changes

* Remove results_ prefix from relations; get specs passing

* Add locals declarations in several views and partial calls

* Set config.cache_classes to false as required by Github CI

* Set config.enable_reloading to true

* Remove old autoload path lib code in favor of config.autoload_lib

* Rework core extensions to reconcile class definitions with directory structure

* Remove `Extensions` from core ext class names

* Require etl/etl in importers

* Trying one more thing to make Github CI happy

* Define ETL module in etl/etl.rb

* Require errors in async importer

* Change capitalization of Etl and Html to make zeitwerk happy

* Fix module namespacing for UrlHelper monkey patch
  • Loading branch information
moveson authored Dec 22, 2024
1 parent 500c70c commit ad6f284
Show file tree
Hide file tree
Showing 147 changed files with 1,035 additions and 794 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ gem "pretender", "~> 0.3", ">= 0.3.4"
gem "progress_bar"
gem "puma"
gem "pundit"
gem "rails", "~> 7.0.0"
gem "rails", "~> 7.1.0"
gem "redis", "~> 4.0"
gem "rest-client"
gem "scenic", ">= 1.5.4"
Expand Down
162 changes: 95 additions & 67 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.8.7)
actionpack (= 7.0.8.7)
activesupport (= 7.0.8.7)
actioncable (7.1.5.1)
actionpack (= 7.1.5.1)
activesupport (= 7.1.5.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.8.7)
actionpack (= 7.0.8.7)
activejob (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
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.0.8.7)
actionpack (= 7.0.8.7)
actionview (= 7.0.8.7)
activejob (= 7.0.8.7)
activesupport (= 7.0.8.7)
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
rails-dom-testing (~> 2.0)
actionpack (7.0.8.7)
actionview (= 7.0.8.7)
activesupport (= 7.0.8.7)
rack (~> 2.0, >= 2.2.4)
rails-dom-testing (~> 2.2)
actionpack (7.1.5.1)
actionview (= 7.1.5.1)
activesupport (= 7.1.5.1)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.8.7)
actionpack (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
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)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.8.7)
activesupport (= 7.0.8.7)
actionview (7.1.5.1)
activesupport (= 7.1.5.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
active_record_query_trace (1.8.2)
activerecord (>= 6.0.0)
active_storage_validations (1.3.5)
Expand All @@ -54,27 +58,35 @@ GEM
activestorage (>= 6.1.4)
activesupport (>= 6.1.4)
marcel (>= 1.0.3)
activejob (7.0.8.7)
activesupport (= 7.0.8.7)
activejob (7.1.5.1)
activesupport (= 7.1.5.1)
globalid (>= 0.3.6)
activemodel (7.0.8.7)
activesupport (= 7.0.8.7)
activerecord (7.0.8.7)
activemodel (= 7.0.8.7)
activesupport (= 7.0.8.7)
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)
timeout (>= 0.4.0)
activerecord-import (2.0.0)
activerecord (>= 4.2)
activestorage (7.0.8.7)
actionpack (= 7.0.8.7)
activejob (= 7.0.8.7)
activerecord (= 7.0.8.7)
activesupport (= 7.0.8.7)
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)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.8.7)
activesupport (7.1.5.1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
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)
acts_as_list (0.9.19)
activerecord (>= 3.0)
Expand Down Expand Up @@ -131,6 +143,7 @@ GEM
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0)
bcrypt (3.1.20)
benchmark (0.4.0)
benchmark-ips (2.14.0)
better_errors (2.10.1)
erubi (>= 1.0.0)
Expand Down Expand Up @@ -212,7 +225,7 @@ GEM
diff-lcs (1.5.1)
domain_name (0.6.20240107)
drb (2.2.1)
erubi (1.13.0)
erubi (1.13.1)
et-orbi (1.2.11)
tzinfo
execjs (2.10.0)
Expand Down Expand Up @@ -259,6 +272,9 @@ GEM
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
io-console (0.8.0)
irb (1.14.3)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jmespath (1.6.2)
jsbundling-rails (1.3.1)
railties (>= 6.0.0)
Expand Down Expand Up @@ -303,7 +319,7 @@ GEM
activesupport (>= 5.2.0)
net-http (0.6.0)
uri
net-imap (0.5.2)
net-imap (0.5.3)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -369,6 +385,9 @@ GEM
pry (0.15.0)
coderay (~> 1.1)
method_source (~> 1.0)
psych (5.2.2)
date
stringio
public_suffix (6.0.1)
puma (6.5.0)
nio4r (~> 2.0)
Expand All @@ -384,20 +403,23 @@ GEM
rack (< 3)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8.7)
actioncable (= 7.0.8.7)
actionmailbox (= 7.0.8.7)
actionmailer (= 7.0.8.7)
actionpack (= 7.0.8.7)
actiontext (= 7.0.8.7)
actionview (= 7.0.8.7)
activejob (= 7.0.8.7)
activemodel (= 7.0.8.7)
activerecord (= 7.0.8.7)
activestorage (= 7.0.8.7)
activesupport (= 7.0.8.7)
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)
bundler (>= 1.15.0)
railties (= 7.0.8.7)
railties (= 7.1.5.1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
Expand All @@ -414,18 +436,21 @@ GEM
json (>= 1.7, < 3)
rails
rubyzip (~> 2)
railties (7.0.8.7)
actionpack (= 7.0.8.7)
activesupport (= 7.0.8.7)
method_source
railties (7.1.5.1)
actionpack (= 7.1.5.1)
activesupport (= 7.1.5.1)
irb
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rdoc (6.10.0)
psych (>= 4.0.0)
redis (4.8.1)
redis-client (0.23.0)
connection_pool
Expand Down Expand Up @@ -491,6 +516,7 @@ GEM
railties (>= 4.0.0)
scout_apm (5.4.0)
parser
securerandom (0.4.1)
selenium-webdriver (4.27.0)
base64 (~> 0.2)
logger (~> 1.4)
Expand Down Expand Up @@ -539,6 +565,7 @@ GEM
statistics (1.0.0)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.2)
strip_attributes (1.14.1)
activemodel (>= 3.0, < 9.0)
structpluck (0.0.1)
Expand Down Expand Up @@ -570,6 +597,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.9.1)
websocket (1.2.11)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
Expand Down Expand Up @@ -639,7 +667,7 @@ DEPENDENCIES
pry
puma
pundit
rails (~> 7.0.0)
rails (~> 7.1.0)
rails-erd
rails_real_favicon (>= 0.1.0)
redis (~> 4.0)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/event_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ def import
authorize @resource

limited_response = params[:limited_response]&.to_boolean
importer = ::ETL::ImporterFromContext.build(@resource, params, current_user)
importer = ::Etl::ImporterFromContext.build(@resource, params, current_user)
importer.import
errors = importer.errors + importer.invalid_records.map { |record| jsonapi_error_object(record) }

if errors.present?
render json: { errors: errors }, status: :unprocessable_entity
else
::ETL::EventGroupImportProcess.perform!(@resource, importer)
::Etl::EventGroupImportProcess.perform!(@resource, importer)
if limited_response
render json: {}, status: :created
else
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "etl/etl"
require "etl"

module Api
module V1
Expand Down Expand Up @@ -53,14 +53,14 @@ def spread
end

def import
importer = ::ETL::ImporterFromContext.build(@event, params, current_user)
importer = ::Etl::ImporterFromContext.build(@event, params, current_user)
importer.import
errors = importer.errors + importer.invalid_records.map { |record| jsonapi_error_object(record) }

if errors.present?
render json: {errors: errors}, status: :unprocessable_entity
else
::ETL::EventImportProcess.perform!(@event, importer)
::Etl::EventImportProcess.perform!(@event, importer)
render json: {}, status: :created
end
end
Expand Down
21 changes: 11 additions & 10 deletions app/controllers/event_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class EventGroupsController < ApplicationController
# GET /event_groups
def index
scoped_event_groups = policy_scope(EventGroup)
.search(params[:search])
.by_group_start_time
.preload(:events)
.paginate(page: params[:page], per_page: 25)
.search(params[:search])
.by_group_start_time
.preload(:events)
.paginate(page: params[:page], per_page: 25)
@presenter = EventGroupsCollectionPresenter.new(scoped_event_groups, params, current_user)
session[:return_to] = event_groups_path
end
Expand Down Expand Up @@ -113,9 +113,9 @@ def setup_summary
# GET /event_groups/1/efforts
def efforts
@efforts = policy_scope(@event_group.efforts)
.order(prepared_params[:sort] || :bib_number, :last_name, :first_name)
.where(prepared_params[:filter])
.finish_info_subquery
.order(prepared_params[:sort] || :bib_number, :last_name, :first_name)
.where(prepared_params[:filter])
.finish_info_subquery

render partial: "event_groups/finish_line_effort", locals: { efforts: @efforts }
end
Expand Down Expand Up @@ -437,9 +437,10 @@ def delete_duplicate_raw_times

private

def bib_assignment_hash(params_hash)
params_hash.select { |key, _| key.include?("bib_for") }
.transform_keys { |key| key.delete("^0-9").to_i }
def bib_assignment_hash(event_group_params)
event_group_params.to_unsafe_h
.select { |key, _| key.include?("bib_for") }
.transform_keys { |key| key.delete("^0-9").to_i }
end

def redirect_if_no_events
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/import_jobs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "etl/etl"
require "etl"

class ImportJobsController < ApplicationController
before_action :authenticate_user!
Expand Down Expand Up @@ -64,7 +64,7 @@ def csv_templates
format.csv do
parent = params[:parent_type].constantize.find(params[:parent_id])
import_job_format = params[:import_job_format].to_sym
csv_template_headers = ::ETL::CsvTemplates.headers(import_job_format, parent)
csv_template_headers = ::Etl::CsvTemplates.headers(import_job_format, parent)
csv_template = csv_template_headers.join(",") + "\n"
filename_components = [import_job_format, parent.class.name.underscore, parent.id, "template.csv"]
filename = filename_components.join("_")
Expand Down
Loading

0 comments on commit ad6f284

Please sign in to comment.