Skip to content

Commit

Permalink
Convert sfruby.info meetup URLs to canonical form
Browse files Browse the repository at this point in the history
  • Loading branch information
tjgrathwell committed Dec 6, 2016
1 parent 271ceef commit bf1fc0d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
@@ -0,0 +1,21 @@
class RegenerateCanonicalSfrubyMeetupUrls < ActiveRecord::Migration
class Event < ActiveRecord::Base
serialize :imported_event_data, JSON
end

def change
# The old format stored was like http://www.sfruby.info/events/13311831/,
# but those URLs don't work anymore for whatever reason.

# URLs of the form https://www.meetup.com/sfruby/events/13311831/
# still work fine.
meetup_events = Event.where.not(imported_event_data: nil)
.select { |e| e.imported_event_data['student_event']['url'].match /sfruby/ }
meetup_events.each do |e|
imported_event_data = e.imported_event_data
imported_event_data['volunteer_event']['url'] = "https://www.meetup.com/sfruby/events/#{imported_event_data['volunteer_event']['id']}/"
imported_event_data['student_event']['url'] = "https://www.meetup.com/sfruby/events/#{imported_event_data['student_event']['id']}/"
e.update_attribute(:imported_event_data, imported_event_data)
end
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20161204040052) do
ActiveRecord::Schema.define(version: 20161206055208) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "unaccent"
Expand Down

0 comments on commit bf1fc0d

Please sign in to comment.