Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrades HackathonManager to Rails 7 #964

Merged
merged 52 commits into from
Feb 9, 2024
Merged

Upgrades HackathonManager to Rails 7 #964

merged 52 commits into from
Feb 9, 2024

Conversation

cbaudouinjr
Copy link
Member

@cbaudouinjr cbaudouinjr commented Feb 5, 2024

It's been a while, huh? After many years and many failed attempts, HackathonManager is now on Rails 7!

There's still plenty of work to go before a release can happen, but this is by far the biggest step.

Unfortunately, this pull request is massive. When I first started this attempt I had little hope and didn't bother with creating bitesized PRs. Fortunately, most of the core application hasn't changed, rather, updated to removed deprecations and other outdates pieces. I made each commit as small as possible, and ran tests for each commit.

I'll try to highlight below where you should look for the biggest changes and which are mostly likely to break.

What's new

  • Upgrade to Rails 7 and Ruby 3 A small detail, I know.
  • Goodbye ajax-datatables-rails! All datatables have been replaced with datatables created with Turbo and Stimulus. This has significantly reduced the amount and complexity of code around a datatable.
  • Many, many gem updates Most of the gems have been updated to a more recent version. Some are held back as they require more intensive refactoring that's outside the scope of this PR. *cough* rails-settings-cached
  • Gitflow HackathonManager will transition into the Gitflow workflow for easier organization and planning.

What to review

  • Datatables There are many changes still to come for the datatables but the general approach should be reviewed. I would look at the questionnaires datatable found in views->manage->questionnaires->_questionnaires_datatable.html.haml. The flow of data starts from the controller then goes to the page hosting the table. From there, the data is fed into the partial.

Closes #965, #966

Gemfile Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
Gemfile Outdated Show resolved Hide resolved
app/views/manage/schools/_schools_datatable.html.haml Outdated Show resolved Hide resolved
app/views/manage/schools/_schools_datatable.html.haml Outdated Show resolved Hide resolved
app/views/manage/schools/_schools_datatable.html.haml Outdated Show resolved Hide resolved
app/views/manage/schools/_schools_datatable.html.haml Outdated Show resolved Hide resolved
.col
= pagy_bootstrap_nav(@applicants_pagy).html_safe
- else
%div{ style: "display:flex; align-items: center; flex-direction: column;" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use inline style attributes

const application = Application.start()

// Configure Stimulus development experience
application.debug = false
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing semicolon.

@@ -0,0 +1,9 @@
import { Application } from "@hotwired/stimulus"

const application = Application.start()
Copy link
Contributor

Choose a reason for hiding this comment

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

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Missing semicolon.

@@ -0,0 +1,9 @@
import { Application } from "@hotwired/stimulus"
Copy link
Contributor

Choose a reason for hiding this comment

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

'import' is only available in ES6 (use 'esversion: 6').
Missing semicolon.

}

submit() {
this.element.requestSubmit()
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing semicolon.


export default class extends Controller {
initialize() {
this.submit = debounce(this.submit.bind(this), 300)
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing semicolon.

import { Controller } from "@hotwired/stimulus";
import debounce from "debounce";

export default class extends Controller {
Copy link
Contributor

Choose a reason for hiding this comment

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

'class' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
'export' is only available in ES6 (use 'esversion: 6').

@@ -0,0 +1,12 @@
import { Controller } from "@hotwired/stimulus";
import debounce from "debounce";
Copy link
Contributor

Choose a reason for hiding this comment

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

'import' is only available in ES6 (use 'esversion: 6').

@@ -0,0 +1,12 @@
import { Controller } from "@hotwired/stimulus";
Copy link
Contributor

Choose a reason for hiding this comment

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

'import' is only available in ES6 (use 'esversion: 6').

app/models/message.rb Outdated Show resolved Hide resolved
db/seeds/development.rb Outdated Show resolved Hide resolved

// Eager load all controllers defined in the import map under controllers/**/*_controller
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
eagerLoadControllersFrom("controllers", application)
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing semicolon.

import { application } from "controllers/application"

// Eager load all controllers defined in the import map under controllers/**/*_controller
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
Copy link
Contributor

Choose a reason for hiding this comment

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

'import' is only available in ES6 (use 'esversion: 6').
Missing semicolon.

@@ -0,0 +1,11 @@
// Import and register all your controllers from the importmap under controllers/*

import { application } from "controllers/application"
Copy link
Contributor

Choose a reason for hiding this comment

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

'import' is only available in ES6 (use 'esversion: 6').
Missing semicolon.

app/models/agreement.rb Outdated Show resolved Hide resolved
= pagy_bootstrap_nav(@bulk_messages_pagy).html_safe

- else
%div{ style: "display:flex; align-items: center; flex-direction: column;" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use inline style attributes

app/models/bus_list.rb Outdated Show resolved Hide resolved
config.options[config.orm][:primary_key_type] || :primary_key
end

def blobs_primary_key_type
Copy link
Contributor

Choose a reason for hiding this comment

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

Layout/IndentationConsistency: Inconsistent indentation detected.

end

private
def primary_key_type
Copy link
Contributor

Choose a reason for hiding this comment

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

Layout/IndentationConsistency: Inconsistent indentation detected.

end
end

private
Copy link
Contributor

Choose a reason for hiding this comment

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

Layout/EmptyLinesAroundAccessModifier: Keep a blank line before and after private.

.col
= pagy_bootstrap_nav(@alt_travel_applicants_pagy).html_safe
- else
%div{ style: "display:flex; align-items: center; flex-direction: column;" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use inline style attributes

.col
= pagy_bootstrap_nav(@applied_pagy).html_safe
- else
%div{ style: "display:flex; align-items: center; flex-direction: column;" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use inline style attributes

.col
= pagy_bootstrap_nav(@sponsor_info_attendees_pagy).html_safe
- else
%div{ style: "display:flex; align-items: center; flex-direction: column;" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use inline style attributes

.col
= pagy_bootstrap_nav(@checked_in_applicants_pagy).html_safe
- else
%div{ style: "display:flex; align-items: center; flex-direction: column;" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use inline style attributes

.col
= pagy_bootstrap_nav(@dietary_restrictions_special_needs_pagy).html_safe
- else
%div{ style: "display:flex; align-items: center; flex-direction: column;" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use inline style attributes

.col
= pagy_bootstrap_nav(@trackable_tags_pagy).html_safe
- else
%div{ style: "display:flex; align-items: center; flex-direction: column;" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use inline style attributes

unless column_exists?(:active_storage_blobs, :service_name)
add_column :active_storage_blobs, :service_name, :string

if configured_service = ActiveStorage::Blob.service.name
Copy link
Contributor

Choose a reason for hiding this comment

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

Lint/AssignmentInCondition: Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.

@@ -7,6 +9,10 @@ class Agreement < ApplicationRecord

has_and_belongs_to_many :questionnaires

def self.ransackable_attributes(_)
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.


has_many :questionnaires

strip_attributes

def self.ransackable_attributes(_)
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.

@@ -49,6 +51,10 @@ class Message < ApplicationRecord
validates_inclusion_of :template, in: POSSIBLE_TEMPLATES
validates_inclusion_of :type, in: POSSIBLE_TYPES

def self.ransackable_attributes(_)
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.

@@ -323,6 +325,10 @@ class Questionnaire < ApplicationRecord
validates_inclusion_of :shirt_size, in: POSSIBLE_SHIRT_SIZES
validates_inclusion_of :acc_status, in: POSSIBLE_ACC_STATUS

def self.ransackable_attributes(_)
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.


strip_attributes

has_many :questionnaires

def self.ransackable_attributes(_)
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.

["created_at", "current_sign_in_at", "current_sign_in_ip", "email", "first_name", "id", "is_active", "last_name", "last_sign_in_at", "last_sign_in_ip", "provider", "receive_weekly_report", "role", "uid"]
end

def self.ransackable_associations(_)
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.

validates_presence_of :first_name, :last_name

after_create :queue_reminder_email
after_initialize :set_default_role, if: :new_record?

enum role: { user: 0, volunteer: 1, organizer: 2, director: 3 }
scope :staff, -> { where(role: [:volunteer, :organizer, :director]) }

def self.ransackable_attributes(_)
Copy link
Contributor

Choose a reason for hiding this comment

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

Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.

@cbaudouinjr cbaudouinjr linked an issue Feb 5, 2024 that may be closed by this pull request
@cbaudouinjr cbaudouinjr merged commit 1bad0fb into develop Feb 9, 2024
2 checks passed
@cbaudouinjr cbaudouinjr deleted the upgrade branch February 9, 2024 02:59
@sman591
Copy link
Member

sman591 commented Feb 9, 2024

Nice! This is awesome

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.

Upgrade to Ruby 3 Upgrade to Rails 7
4 participants