Skip to content

Commit

Permalink
Merge pull request hackclub#337 from hackclub/remove-old-fields-from-…
Browse files Browse the repository at this point in the history
…email

Remove video URL and interesting projects questions from new club applications
  • Loading branch information
zachlatta authored Jan 27, 2018
2 parents 796fd20 + 7b28a78 commit 282d351
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 17 deletions.
6 changes: 6 additions & 0 deletions api/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,9 @@ Rails/InverseOf:
# Don't force :dependent to be specified beacuse :nullify is a sane default.
Rails/HasManyOrHasOneDependent:
Enabled: false

# Don't force usage of ApplicationRecord instead of ActiveRecord::Base in Rails
# migrations because migrations shouldn't depend on application code.
Rails/ApplicationRecord:
Exclude:
- 'db/migrate/**'
2 changes: 0 additions & 2 deletions api/app/controllers/v1/new_club_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ def club_application_params
:high_school_url,
:high_school_type,
:high_school_address,
:leaders_video_url,
:leaders_interesting_project,
:leaders_team_origin_story,
:progress_general,
:progress_student_interest,
Expand Down
6 changes: 0 additions & 6 deletions api/app/mailers/applicant_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ def application_fields(application)
'High School Website': application.high_school_url,
'High School Type': application.high_school_type.humanize,
'High School Address': application.high_school_address,
'Video URL': application.leaders_video_url,

'Please tell us about an interesting project, preferably outside of '\
'class, that two or more of you created together. Include URLs if '\
'possible.' =>
application.leaders_interesting_project,

'How long have you known your other club leaders and how did you meet?':
application.leaders_team_origin_story,
Expand Down
2 changes: 0 additions & 2 deletions api/app/serializers/new_club_application_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class NewClubApplicationSerializer < ActiveModel::Serializer
:high_school_parsed_postal_code,
:high_school_parsed_country,
:high_school_parsed_country_code,
:leaders_video_url,
:leaders_interesting_project,
:leaders_team_origin_story,
:progress_general,
:progress_student_interest,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddLegacyFieldsToNewClubApplications < ActiveRecord::Migration[5.1]
def change
add_column :new_club_applications, :legacy_fields, :json
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

class RemoveVideoUrlFromNewClubApplications < ActiveRecord::Migration[5.1]
class NewClubApplications < ActiveRecord::Base; end

def up
NewClubApplications.find_each do |app|
if app.leaders_video_url
app.legacy_fields ||= {}
app.legacy_fields['Video URL'] = app.leaders_video_url
app.save
end
end

remove_column :new_club_applications, :leaders_video_url
end

def down
add_column :new_club_applications, :leaders_video_url, :text

NewClubApplications.find_each do |app|
app.legacy_fields ||= {}

video = app.legacy_fields['Video URL']

if video
app.leaders_video_url = video
app.legacy_fields.delete('Video URL')
app.save
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

class RemoveLeadersProjectFromNewClubApplications < ActiveRecord::Migration[5.1]
class NewClubApplications < ActiveRecord::Base; end

QUESTION = 'Please tell us about an interesting project, preferably outside '\
'of class, that two or more of you created together. Include URLs if '\
'possible.'

def up
NewClubApplications.find_each do |app|
if app.leaders_interesting_project
app.legacy_fields ||= {}
app.legacy_fields[QUESTION] = app.leaders_interesting_project
app.save
end
end

remove_column :new_club_applications, :leaders_interesting_project
end

def down
add_column :new_club_applications, :leaders_interesting_project, :text

NewClubApplications.find_each do |app|
app.legacy_fields ||= {}

interesting_project = app.legacy_fields[QUESTION]

if interesting_project
app.leaders_interesting_project = interesting_project
app.legacy_fields.delete(QUESTION)
app.save
end
end
end
end
5 changes: 2 additions & 3 deletions api/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180115122359) do
ActiveRecord::Schema.define(version: 20180127051157) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -268,8 +268,6 @@
t.text "high_school_parsed_postal_code"
t.text "high_school_parsed_country"
t.text "high_school_parsed_country_code"
t.text "leaders_video_url"
t.text "leaders_interesting_project"
t.text "leaders_team_origin_story"
t.text "progress_general"
t.text "progress_student_interest"
Expand All @@ -286,6 +284,7 @@
t.text "other_surprising_or_amusing_discovery"
t.integer "point_of_contact_id"
t.datetime "submitted_at"
t.json "legacy_fields"
t.index ["point_of_contact_id"], name: "index_new_club_applications_on_point_of_contact_id"
end

Expand Down
2 changes: 0 additions & 2 deletions api/spec/factories/new_club_applications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
high_school_address { HCFaker::Address.full_address }

# leaders
leaders_video_url { Faker::Internet.url }
leaders_interesting_project { Faker::Lorem.paragraph }
leaders_team_origin_story { Faker::Lorem.paragraph }

# progress
Expand Down
2 changes: 0 additions & 2 deletions api/spec/models/new_club_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
it { should have_db_column :high_school_parsed_country_code }

# leaders
it { should have_db_column :leaders_video_url }
it { should have_db_column :leaders_interesting_project }
it { should have_db_column :leaders_team_origin_story }

# progress
Expand Down

0 comments on commit 282d351

Please sign in to comment.