Skip to content

Conversation

@reedstrm
Copy link
Contributor

@reedstrm reedstrm commented Jun 6, 2019

Completed upgrade to 5.2.3
Most of the work was converting squeel based DB queries to a combination of ActiveRecord and arel,
followed by converting to new defaults for model belong_to behavior, and controller spec parameter passing.

@reedstrm reedstrm changed the title WIP Upgrade rails 5 Upgrade rails 5 Jun 7, 2019
@reedstrm reedstrm requested a review from Dantemss June 7, 2019 20:10
Copy link
Member

@Dantemss Dantemss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I think the 3 important comments are the one about rendering errors in exercises_controller and the 2 about whitespace between a method and the argument list. The rest is all minor.

Gemfile Outdated

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.11'
gem 'rails', '~> 5.2'
Copy link
Member

@Dantemss Dantemss Jun 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ok for 5.2 because there is no Rails 5.3 (Rails goes from 5.2 to 6.0)
But in general we want to avoid this, as it allows upgrading to the next minor version, which with Rails usually means breaking a lot of things as you've seen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point. Will fix.

Gemfile Outdated

# Talks to Accounts (latest version is broken)
gem 'omniauth-oauth2', '~> 1.3.1'
# gem 'omniauth-oauth2', '~> 1.3.1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove the commented out one

Gemfile Outdated
gem 'mini_magick'

# Markdown parsing
# Pinned for Rails 4.X
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment can be removed too

Gemfile Outdated
gem 'scout_apm', '~> 3.0.x'

# PostgreSQL database
# Pinned for rails 4.X
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah hah, but I need to unpin, if I remove the comment. Yay for comments!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unpinned, and comment deleted.

Gemfile Outdated

# Mute asset pipeline log messages
gem 'quiet_assets'
# gem 'quiet_assets'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this one too. And the 2 pinned comments below.

elsif sanitized_versions.empty?
@items = @items.where(publication_groups: { number: sanitized_numbers })
else
# Combine the id's one at a time using Squeel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment can be removed :)

next @items = @items.none if sanitized_names.empty?

@items = @items.where { name.like_any sanitized_names }
@items = @items.where ( vt[:name].matches_any(sanitized_names ))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The space between the where and the parenthesis should be removed too. There's no semantic difference here right now because nothing is chained to the where, but it could become a problem one day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did a recursive search for '\(where\|order\)\s(' and you caught them all! (both) Good eye.

end

with.keyword :content do |contents|
vt = VocabTerm.arel_table
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just put these at the top of the method, since they are everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah my peep-hole-optimizer-like conversion process didn't push things to lowest-common-namespace very well. I'll see what I can do. There are currently 150 .arel_table refs in 20 files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok refactored positions of arel_table for a couple of these. I do like to keep the variable defs near their use, but in this case, they get reused a lot, across diff. methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also moved most of them out of the local loop they where in

end
alias_method_chain :add_link, :attachments
alias_method :add_link_without_attachments, :add_link
alias_method :add_link, :add_link_with_attachments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe manual alias_method_chain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I spent 1/2 a day on this, and punted. Came this close to understanding how to do it with a module and prepend/super, but … realized this is used only in the deprecated importer, anyways.

@@ -0,0 +1,7 @@
# This migration comes from openstax_accounts (originally 13)
class AddSchoolTypeToAccountsAccounts < ActiveRecord::Migration[4.2][4.2]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double [4.2] here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dang sed. fixed.

@Dantemss
Copy link
Member

Dantemss commented Jun 7, 2019

Apparently I commented too much so github hid half of my comments, so look for the button to show them above.

@reedstrm
Copy link
Contributor Author

@Dantemss all fixed

@Dantemss
Copy link
Member

The only thing I think it still needs is to add a render_api_errors(publication.errors) in the exercises controller create action just in case the publication has errors but the exercise/publication_group don't. The rest looks good.

@reedstrm
Copy link
Contributor Author

Fixed that in ed145b9 (I also unwrapped it onto three lines)

@reedstrm
Copy link
Contributor Author

I told code climate that I'm not fixing any of that. :)

@Dantemss Dantemss merged commit 52b4fdc into master Jun 11, 2019
@Dantemss Dantemss deleted the upgrade-rails-5 branch June 11, 2019 14:50
@staxly
Copy link

staxly bot commented Jun 11, 2019

This PR landed in v25.0.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants