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
#extend this from Athlete model | |
module Extensions::AthleteSearch | |
extend ActiveSupport::Concern | |
included do | |
searchable :auto_index => true, :auto_remove => true do | |
# all your searchable code | |
end | |
end | |
end |
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
require 'sidekiq' | |
require 'autoscaler/sidekiq' | |
require 'autoscaler/heroku_scaler' | |
heroku = nil | |
if ENV['HEROKU_APP'] | |
heroku = Autoscaler::HerokuScaler.new | |
end | |
Sidekiq.configure_server do |config| |
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 self.unique(coaches) | |
return coaches if coaches.empty? | |
raise ArgumentError, "requires array of coaches as an argument" if(coaches.class != Array || coaches.first.class != Coach) | |
coach_ids = [] | |
unique_coaches = [] | |
coaches.each do |coach| | |
unless coach_ids.include?(coach.id) | |
coach_ids << coach.id | |
unique_coaches << coach | |
end |
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
<% for coach in @interested_coaches do %> | |
<%= time_ago_in_words coach.interested_at %> | |
<% end %> |
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
## coach.rb | |
attr_accessor :interested_at | |
## athletes_controller.rb | |
coach_bookmarks = bookmarks.map do |bookmark| | |
coach = bookmark.coach | |
coach.interested_at = bookmark.created_at | |
coach | |
end |
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
@coaches = bookmarks.map{|bookmark| bookmark.coach} + connections.map{|connection| connection.coach} | |
@interested_coaches = Coach.unique(@coaches) # I created a custom unique handler for Coach objects |
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
bookmarks = Bookmark.find(:all, :conditions => ['athlete_id = ?', @athlete.id], :include => :coach) |
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
connections = Connection.find(:all, :conditions => ['athlete_id = ?', @athlete.id], :include => :coach) |
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
// assuming we already have the query created, wait on it with a callback | |
query.wait(function(permissions){ | |
// master list for granted permissions | |
var grantedPermissions = new Array(); | |
// your basicPerms converted into an array "read_stream,user_interests" | |
var permArray = new Array(); | |
permArray = basicPerms.split(","); | |
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
var basicPerms = "read_stream,user_interests"; | |
var queryString = 'select ' + basicPerms + ' from permissions where uid=me()'; | |
var query = FB.Data.query(queryString); |