Last active
August 29, 2015 14:18
-
-
Save simonv3/9e3f9d6c2694b21134eb to your computer and use it in GitHub Desktop.
Various OpenFarm Shorts
This file contains hidden or 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
# Using Gibbon, go through the mailing list and update any old users. | |
gb = Gibbon::API.new | |
list = gb.lists.list({ filters: { list_name: 'Subscribers' } }) | |
list_id = list['data'][0]['id'] | |
# don't need the below two things because Mailchimp actually doesn't allow resubscription. | |
# unsubscribed = gb.lists.members({:id => list_id, :status => "unsubscribed"}) | |
# unsubscribed_emails = unsubscribed['data'].map{ |us| us.email } | |
new_users = User.all.reject{|u| u.mailing_list == false} | |
new_emails = new_users.map{|u| {email: {email: u.email}, merge_vars: {DNAME: u.display_name}}} | |
gb.lists.batch_subscribe(:id => list_id, | |
:batch => new_emails, | |
:update_existing => true, | |
:double_optin => false) |
This file contains hidden or 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
# Move things from user to user_setting | |
User.all.each do |u| | |
if u.years_experience != '' | |
u.user_setting.years_experience = u.years_experience | |
end | |
if u.units != '' | |
u.user_setting.units = u.units | |
end | |
if u.location != '' | |
u.user_setting.location = u.location | |
end | |
u.save | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment