Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert sfruby.info meetup URLs to canonical form
- Loading branch information
1 parent
271ceef
commit bf1fc0d
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
db/migrate/20161206055208_regenerate_canonical_sfruby_meetup_urls.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters