Created
September 19, 2010 02:32
-
-
Save jeffdeville/586302 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dopplegangers() | |
raise StandardError.new("insufficient interests") unless interests.size >= MINIMUM_INTERESTS | |
usr_ints = interests.collect { |c| c.facebook_id } | |
matches = User.collection.find({ | |
:facebook_id => {"$ne" => facebook_id}, #don't use current user | |
:access_token => {"$ne" => nil}, # access_token = activeuser | |
"interests.facebook_id" => {"$in" => usr_ints}}, # load all where at least 1 interest shared | |
{:fields => [:facebook_id, :interests]}).to_a | |
matches.each {|match| match[:score] = calculate_score(match) } | |
matches.sort{|x,y| y[:score] <=> x[:score]} | |
end | |
# Similarity Score Math (for now) | |
# num_shared_interests / (num_interests_for_user_1 + num_interests_for_user_2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment