Start saving the usernames of facebook users
This commit is contained in:
parent
2f3e504811
commit
31b55aef0b
3 changed files with 17 additions and 7 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
11
db/schema.rb
11
db/schema.rb
|
|
@ -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
|
||||||
|
|
@ -319,16 +319,17 @@ ActiveRecord::Schema.define(:version => 20110730173443) do
|
||||||
add_index "profiles", ["person_id"], :name => "index_profiles_on_person_id"
|
add_index "profiles", ["person_id"], :name => "index_profiles_on_person_id"
|
||||||
|
|
||||||
create_table "service_users", :force => true do |t|
|
create_table "service_users", :force => true do |t|
|
||||||
t.string "uid", :null => false
|
t.string "uid", :null => false
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
t.string "photo_url", :null => false
|
t.string "photo_url", :null => false
|
||||||
t.integer "service_id", :null => false
|
t.integer "service_id", :null => false
|
||||||
t.integer "person_id"
|
t.integer "person_id"
|
||||||
t.integer "contact_id"
|
t.integer "contact_id"
|
||||||
t.integer "request_id"
|
t.integer "request_id"
|
||||||
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"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue