VRFS-3036 band query
This commit is contained in:
parent
cb7b48b4ec
commit
2f28d3a342
|
|
@ -42,9 +42,9 @@ module JamRuby
|
|||
}
|
||||
|
||||
PLAY_COMMIT_VALS = [ANY_VAL_STR,
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
]
|
||||
PLAY_COMMITS = {
|
||||
PLAY_COMMIT_VALS[0] => 'Any',
|
||||
|
|
@ -117,31 +117,38 @@ module JamRuby
|
|||
super(rel, filter)
|
||||
end
|
||||
|
||||
def _instruments(rel, filter)
|
||||
rel
|
||||
end
|
||||
|
||||
def _concert_gigs(rel, filter)
|
||||
gg = filter[KEY_GIGS].to_i
|
||||
rel = rel.where(concert_count: gg) if 0 <= gg
|
||||
rel
|
||||
end
|
||||
|
||||
def _band_type(rel, filter)
|
||||
case filter[KEY_BAND_TYPE]
|
||||
when GenrePlayer::VIRTUAL_BAND: rel.where(band_type: GenrePlayer::VIRTUAL_BAND)
|
||||
when GenrePlayer::TRADITIONAL_BAND: rel.where(band_type: GenrePlayer::TRADITIONAL_BAND)
|
||||
default: rel
|
||||
when GenrePlayer::VIRTUAL_BAND
|
||||
rel.where(band_type: GenrePlayer::VIRTUAL_BAND)
|
||||
when GenrePlayer::TRADITIONAL_BAND
|
||||
rel.where(band_type: GenrePlayer::TRADITIONAL_BAND)
|
||||
else
|
||||
rel
|
||||
end
|
||||
end
|
||||
|
||||
def _play_commit(rel, filter)
|
||||
unless ANY_VAL_STR == filter[KEY_PLAY_COMMIT]
|
||||
rel = rel.where(play_commitment: filter[KEY_PLAY_COMMIT].to_i)
|
||||
end
|
||||
rel
|
||||
end
|
||||
|
||||
def _tour_option(rel, filter)
|
||||
case filter[KEY_TOUR_OPTION]
|
||||
when 'yes': rel.where(touring_option: true)
|
||||
when 'no': rel.where(touring_option: false)
|
||||
default: rel
|
||||
when 'yes'
|
||||
rel.where(touring_option: true)
|
||||
when 'no'
|
||||
rel.where(touring_option: false)
|
||||
else
|
||||
rel
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -150,19 +157,33 @@ module JamRuby
|
|||
end
|
||||
|
||||
def _max_cost(rel, filter)
|
||||
if 0 < (max_cost = filter[KEY_HIRE_MAX_COST].to_i)
|
||||
col = Band.arel_table[:gig_minimum]
|
||||
rel = rel.where(col.lteq(max_cost))
|
||||
end
|
||||
rel
|
||||
end
|
||||
|
||||
def _free_gigs(rel, filter)
|
||||
case filter[KEY_FREE_GIGS]
|
||||
when 'yes': rel.where(free_gigs: true)
|
||||
when 'no': rel.where(free_gigs: false)
|
||||
default: rel
|
||||
when 'yes'
|
||||
rel.where(free_gigs: true)
|
||||
when 'no'
|
||||
rel.where(free_gigs: false)
|
||||
else
|
||||
rel
|
||||
end
|
||||
end
|
||||
|
||||
def _skill_level(rel, filter)
|
||||
rel
|
||||
case filter[KEY_SKILL_LEVEL].to_i
|
||||
when SKILL_VALS[1]
|
||||
rel.where(free_gigs: true)
|
||||
when SKILL_VALS[2]
|
||||
rel.where(paid_gigs: true)
|
||||
else
|
||||
rel
|
||||
end
|
||||
end
|
||||
|
||||
def do_search(filter)
|
||||
|
|
|
|||
|
|
@ -111,6 +111,14 @@ module JamRuby
|
|||
end
|
||||
|
||||
def _instruments(rel)
|
||||
unless (instruments = json[KEY_INSTRUMENTS]).blank?
|
||||
instsql = "SELECT player_id FROM musicians_instruments WHERE (("
|
||||
instsql += instruments.collect do |inst|
|
||||
"instrument_id = '#{inst['instrument_id']}' AND proficiency_level = #{inst['proficiency_level']}"
|
||||
end.join(") OR (")
|
||||
instsql += "))"
|
||||
rel = rel.where("#{self.class.search_target_class.table_name}users.id IN (#{instsql})")
|
||||
end
|
||||
rel
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -69,18 +69,6 @@ module JamRuby
|
|||
User
|
||||
end
|
||||
|
||||
def _instruments(rel)
|
||||
unless (instruments = json['instruments']).blank?
|
||||
instsql = "SELECT player_id FROM musicians_instruments WHERE (("
|
||||
instsql += instruments.collect do |inst|
|
||||
"instrument_id = '#{inst['instrument_id']}' AND proficiency_level = #{inst['proficiency_level']}"
|
||||
end.join(") OR (")
|
||||
instsql += "))"
|
||||
rel = rel.where("users.id IN (#{instsql})")
|
||||
end
|
||||
rel
|
||||
end
|
||||
|
||||
def _ages(rel)
|
||||
unless (vals = json[KEY_AGES]).blank?
|
||||
return rel if vals.detect { |vv| ANY_VAL_INT == vv }
|
||||
|
|
|
|||
Loading…
Reference in New Issue