Start saving the usernames of facebook users

This commit is contained in:
Raphael Sofaer 2011-08-12 11:51:06 -07:00
parent 2f3e504811
commit 31b55aef0b
3 changed files with 17 additions and 7 deletions

View file

@ -38,11 +38,11 @@ class Services::Facebook < Service
data = JSON.parse(response.body)['data'] data = JSON.parse(response.body)['data']
return unless data return unless data
data.map!{ |p| data.map!{ |p|
su = ServiceUser.new(:service_id => self.id, :uid => p["id"], :photo_url => p["picture"], :name => p["name"]) su = ServiceUser.new(:service_id => self.id, :uid => p["id"], :photo_url => p["picture"], :name => p["name"], :username => p["username"])
su.attach_local_models su.attach_local_models
su su
} }
ServiceUser.import(data, :on_duplicate_key_update => [:updated_at, :contact_id, :person_id, :request_id, :invitation_id, :photo_url, :name]) ServiceUser.import(data, :on_duplicate_key_update => [:updated_at, :contact_id, :person_id, :request_id, :invitation_id, :photo_url, :name, :username])
end end
private private

View file

@ -0,0 +1,9 @@
class AddUsernameToServiceUsers < ActiveRecord::Migration
def self.up
add_column :service_users, :username, :string, :limit => 127
end
def self.down
remove_column :service_users, :username
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110730173443) do ActiveRecord::Schema.define(:version => 20110812175614) do
create_table "aspect_memberships", :force => true do |t| create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false t.integer "aspect_id", :null => false
@ -329,6 +329,7 @@ ActiveRecord::Schema.define(:version => 20110730173443) do
t.integer "invitation_id" t.integer "invitation_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "username", :limit => 127
end end
add_index "service_users", ["service_id"], :name => "index_service_users_on_service_id" add_index "service_users", ["service_id"], :name => "index_service_users_on_service_id"