lena / likes_me

0 stars 1 forks source link

LIKES ME

Find your best facebook photos!

Visit

HEROKU: http://likes-me.herokuapp.com

Screenshots

Example1

  1. Organize photos by popularity (All Likes, By Females, By Males)

Example1

  1. Another example. Find your most liked images!

Example1

  1. Export directly to OkCupid and tinder - not yet implemented

Testing!

Testing coverage

Implementation

Incorporates Facebook's Graph API using the Koala gem. Uses batched facebook queries to improve efficiency and reduce API calls.

In the example below, in order to organize "Likes" by gender, data related to each user that has "Liked" an individual photo is retrieved in the same API call as the list of each photo's associated "Likes".

  def self.populate_likes_and_tags!(photos, graph)
    photos.each do |photo|
      photo["tag_count"] = graph.get_connection( photo["id"], "tags" ).count

      results = graph.batch do |batch_api|
        batch_api.get_connections(photo["id"], "likes", {:limit => 25}, :batch_args => {:name => "get-likes", :omit_response_on_success => false})
        batch_api.get_objects("{result=get-likes:$.data.*.id}")  
      end

      male_likes = 0
      female_likes = 0
      if results[1].class == Hash   
        results[1].each do |k,v|
          if v["gender"] == "male"
            male_likes += 1
          else
            female_likes += 1
          end
        end
      end

      photo["male_likes"] = male_likes
      photo["female_likes"] = female_likes
    end
  end

Thanks for visiting!!