module Flocks::Search
Public Instance Methods
search_followers(query)
click to toggle source
Search
a user’s list of followers
# File lib/flocks/search.rb, line 10 def search_followers(query) redis.zrangebyscore relationship_followers_key, start_score(query), stop_score(query) end
search_following(query)
click to toggle source
Search
a user’s list of following
# File lib/flocks/search.rb, line 5 def search_following(query) redis.zrangebyscore relationship_following_key, start_score(query), stop_score(query) end
search_graph(query)
click to toggle source
Search
a user’s entire social graph
# File lib/flocks/search.rb, line 15 def search_graph(query) (search_following(query) + search_followers(query)).uniq end
Protected Instance Methods
start_score(query)
click to toggle source
Set constraints to return relevent results Starting score for redis zrangebyscore
# File lib/flocks/search.rb, line 23 def start_score(query) rank_username(query) end
stop_score(query)
click to toggle source
‘aaa’ -> ‘aab’ Ending score for redis zrangebyscore
# File lib/flocks/search.rb, line 29 def stop_score(query) query_array = query.chars last_char = (query_array.pop.ord + 1).chr stop_name = query_array.push(last_char).join('') rank_username(stop_name) end