VRFS-2795 interests filter
This commit is contained in:
parent
88315fcc40
commit
171dcb04f0
|
|
@ -4,8 +4,8 @@ module JamRuby
|
|||
PROFILE = 'profile'
|
||||
VIRTUAL_BAND = 'virtual_band'
|
||||
TRADITIONAL_BAND = 'traditional_band'
|
||||
PAID_SESSION = 'paid_session'
|
||||
FREE_SESSION = 'free_session'
|
||||
PAID_SESSION = 'paid_sessions'
|
||||
FREE_SESSION = 'free_sessions'
|
||||
COWRITING = 'cowriting'
|
||||
|
||||
self.table_name = "genre_players"
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ module JamRuby
|
|||
KEY_SKILL = 'skill_level'
|
||||
KEY_GENRES = 'genres'
|
||||
KEY_INSTRUMENTS = 'instruments'
|
||||
KEY_INTERESTS = 'interests'
|
||||
|
||||
SORT_VALS = %W{ latency distance }
|
||||
SORT_ORDERS = {
|
||||
|
|
@ -82,7 +83,7 @@ module JamRuby
|
|||
JSON_SCHEMA = {
|
||||
:sort_order => '',
|
||||
KEY_INSTRUMENTS => [],
|
||||
:interests => '',
|
||||
KEY_INTERESTS => '',
|
||||
KEY_GENRES => [],
|
||||
KEY_GIGS => 0,
|
||||
KEY_STUDIOS => '',
|
||||
|
|
@ -197,8 +198,7 @@ module JamRuby
|
|||
def _interests(rel)
|
||||
val = json['interests']
|
||||
if val.present? && ANY_VAL_STR != val
|
||||
rel = rel.joins("RIGHT JOIN genre_players AS interest ON interest.player_id = users.id")
|
||||
.where(['interest..genre_type = ? AND users.id IS NOT NULL', val])
|
||||
rel = rel.where("#{val} = ?", true)
|
||||
end
|
||||
rel
|
||||
end
|
||||
|
|
|
|||
|
|
@ -128,7 +128,18 @@ describe 'Musician Search Model' do
|
|||
end
|
||||
end
|
||||
|
||||
it "filters interests" do
|
||||
describe "filters interests" do
|
||||
before(:all) do
|
||||
User.delete_all
|
||||
MusicianSearch::INTEREST_VALS[1..-1].each do |val|
|
||||
user_types.each { |utype| FactoryGirl.create(utype, val => true) }
|
||||
end
|
||||
end
|
||||
|
||||
it "get expected number per interest" do
|
||||
search.update_json_value(MusicianSearch::KEY_INTERESTS, MusicianSearch::INTEREST_VALS[1])
|
||||
expect(search.do_search.count).to eq(user_types.count)
|
||||
end
|
||||
end
|
||||
|
||||
describe "filters genres" do
|
||||
|
|
|
|||
Loading…
Reference in New Issue