Skip to content

Instantly share code, notes, and snippets.

@bastosmichael
Last active March 11, 2016 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastosmichael/9db6e76bf14f108e2415 to your computer and use it in GitHub Desktop.
Save bastosmichael/9db6e76bf14f108e2415 to your computer and use it in GitHub Desktop.
User information
facebook_ids = [
"cirospizzeriabeerhousegaslamp",
"lavalenciahotel",
"tendergreensfood",
"craftpizzaco",
"tapiocaexpress",
"singlefinsd",
"thebakedbear",
"artofespresso",
"julianbakery",
"theduckdive",
"thefisherysd",
"westendpb",
"175450065799869",
"121921894540281",
"fatsalsdeli",
"146013036729",
"harryscoffeeshop",
"herringboneeats",
"aroicafe",
"thefrenchgourmet",
"goporkyland",
"carlsjr",
"sugarandscribebakery",
"pacificbeachsd",
"pacificbeachshoreclub",
"rimelsrestaurants",
"pbfishshop",
"seasons52",
"woodstockspb",
"crabcatcherrestaurant",
"theturquoisehome",
"lodgetorreypines",
"burgerlounge",
"cabocantinabrentwood",
"roysrestaurant",
"eatpuesto",
"thecottagelajolla",
"isabella.lovin",
"wahoosfishtaco",
"whisknladlerestaurant",
"chedithai",
"brocktonvilla",
"108276955864187",
"eddievsprimeseafood",
"manhattanoflajolla",
"dlushlife",
"biteofboston",
"thehake",
"georgesatthecove",
"kwikfill",
"thrusterslounge",
"45664163027",
"marineroom",
"sdsubookstore",
"followcpc",
"tacosurf",
"157031437646026",
"elixirespressobar",
"tower23",
"rubicondeli",
"schlotzskys",
"217993311551780",
"sunsettrocadero",
"tapenaderestaurant",
"carinositalian",
"boomerangsburgerjoint",
"birdrockcoffeeroasters",
"hiltonlajollatorreypines",
"theflamebroiler",
"bombaycompany",
"donovanssteakandchophouse",
"catamaranresort",
"flytpg",
"116208461740332",
"shakesmart",
"shakeawayland",
"noodlesandcompanyvalleywestmall",
"haagendazsus",
"wetzelspretzels",
"710beachclubpb",
"estancialajolla",
"brokenyolkcafe",
"firehousesd",
"ironpigalehouse",
"vacanteenservice",
"WFMlajolla",
"ljshoreshotel",
"perkybeanscoffee",
"glassdoorsd",
"doubletreedowntown",
"buddhagroove",
"teksalonandspa",
"heatherchastyles",
"sohofashioninc",
"platformsalon",
"sandiegostyleweddingsmagazine",
"styleseat",
"154255451263878",
"kutnbeautypicorivera",
"270510862980153",
"signaturehomestylesus",
"thestyleloungecarlsbad",
"127914767254061",
"homeadvisor",
"beauty.com",
"Hairsaloninmissionviejo"
].uniq
instagram_ids = [
"barwestsd",
"lavalenciahotel",
"tendergreens",
"eatcraftpizza",
"singlefinsd",
"thebakedbear",
"julianbakery",
"theduckdive",
"westendpb",
"livingroomcafebyeplus",
"fatsalsdeli",
"harryscoffeeshop",
"herringboneeats",
"sugarandscribe",
"pacificbeachsandiego1969",
"pbshoreclub",
"rimelsrotisserie",
"seasons52",
"woodstockspizza",
"theturquoiseiris",
"lodgetorreypines",
"burgerlounge",
"cabocantina",
"eatpuesto",
"thecottagelajolla",
"isabella.sd",
"wahoosfishtaco",
"whisknladle",
"chedithaibistro",
"brocktonvilla",
"dirtybirdspb",
"bestwestern",
"eddievs_",
"dlushlife",
"thehakelj",
"treyfoshee",
"themeltingpot",
"crownpointcoffee",
"fredshb",
"prospectbar",
"elixirespressobar",
"jrdn.c",
"rubicondeli",
"schlotzskys",
"pbcantina",
"tapenade.restaurant",
"birdrockcoffeeroasters",
"theflamebroiler",
"catamaranresortsandiego",
"russoshouseofpizza",
"shakesmart",
"noodlescompany",
"haagendazs_us",
"710beachclub",
"firehousepb",
"ironpigalehouse",
"wfmlajolla",
"perkybeanscoffee",
"starbucks",
"teksalonandspa",
"heatherchastyles",
"shopsohostyle",
"bridgenott_stylist",
"kutnbeautypicorivera",
"luigis_barbers",
"hairaffairvh",
"stylesbarberspa",
"Instylebyingrid"
].uniq
handles = (facebook_ids.map {|id| facebook(id) }.flatten + instagram_ids.map {|id| instagram(id) }.flatten).compact.uniq
CanonicalUser.where(handle: handles).where('id_klout_handle IS NULL').pluck(:handle).with_progress.each {|handle| Crawler::Klout.perform_async handle }
CanonicalUser.where(handle: handles).where('id_klout_handle IS NULL').pluck(:handle).with_progress.each {|handle| begin test = Crawler::Klout.new; test.perform handle rescue ap handle end }
CanonicalUser.where(handle: handles).where('first_name IS NULL or last_name IS NULL').find_each.with_progress.each do |u|
begin
if object = FacebookUser.find_by(handle: u.handle)
u.first_name = object.first unless u.first_name
u.last_name = object.last unless u.last_name
u.middle_name = object.middle unless u.middle_name
u.id_fb_handle = object.handle unless u.id_fb_handle
u.save
end
rescue
ap u
end
end
CanonicalUser.where(handle: handles).where('first_name IS NULL or last_name IS NULL').find_each.with_progress.each do |u|
begin
if object = InstagramUser.find_by(handle: u.handle)
u.first_name = object.name.split(' ').first unless u.first_name
u.last_name = object.name.split(' ').last unless object.name.split(' ').count == 1 || u.last_name
u.id_inst_handle = object.handle unless u.id_inst_handle
u.save
end
rescue
ap u
end
end
require 'csv'
CSV.open("/home/michael/users_test2.csv", "wb") do |csv|
csv << CanonicalUser.attribute_names
CanonicalUser.where(handle: handles).where('first_name IS NOT NULL').with_progress.each do |user|
csv << user.attributes.values
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment