Skip to content
Extraits de code Groupes Projets
Valider f3ced6d9 rédigé par danielvincent's avatar danielvincent
Parcourir les fichiers

randomize collections of similar contacts on people#show

parent b4b61893
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -49,13 +49,24 @@ class ApplicationController < ActionController::Base
end
end
def similar_people contact
def similar_people contact, opts={}
opts[:limit] ||= 5
aspect_ids = contact.aspect_ids
count = Contact.count(:user_id => current_user.id,
:person_id.ne => contact.person.id,
:aspect_ids.in => aspect_ids)
if count > opts[:limit]
offset = rand(count-opts[:limit])
else
offset = 0
end
contacts = Contact.all(:user_id => current_user.id,
:person_id.ne => contact.person.id,
:aspect_ids.in => aspect_ids,
:limit => 5,
:order => 'updated_at desc')
:skip => offset,
:limit => opts[:limit])
contacts.collect!{ |contact| contact.person }
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter