Skip to content

Instantly share code, notes, and snippets.

@mazikwyry
Created July 25, 2013 11:49
Show Gist options
  • Save mazikwyry/6078958 to your computer and use it in GitHub Desktop.
Save mazikwyry/6078958 to your computer and use it in GitHub Desktop.
optymilzacja
@contacts = User.fetch_contacts("Linkedin", current_user) //lista kontaktw
@tmps = @contacts.map { |tmp| tmp[:id] } //wybieramy z nij liste idków
@registered = Authentication.where("uid IN (:uids)", :uids => @tmps) //szukamy userów o takich idkach w bazie (to chyba zajmuje najwięcej czasu)
@contacts.delete_if{|contact| @registered.pluck(:uid).include?(contact[:id])} // wyrzucamy z kontaktów te znalezione w bazie
@registered.map! { |auth| auth.user }
@registered = ContactsInviterController::remove_invited @registered, current_user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment