removed latency as search; fixed regressions
This commit is contained in:
parent
4f897fc6aa
commit
4f2f37f7a9
|
|
@ -31,11 +31,15 @@ module JamRuby
|
|||
BAND_TYPE_VAL_STRS[2] => BAND_TYPE_VAL_STRS[2].camelcase,
|
||||
}
|
||||
|
||||
SORT_VALS = %W{ distance latency }
|
||||
SORT_VALS = %W{ distance }
|
||||
SORT_ORDERS = {
|
||||
SORT_VALS[0] => 'Distance to Me',
|
||||
SORT_VALS[1] => 'Latency to Me',
|
||||
SORT_VALS[0] => 'Distance to Me'
|
||||
}
|
||||
# SORT_VALS = %W{ distance latency }
|
||||
# SORT_ORDERS = {
|
||||
# SORT_VALS[0] => 'Distance to Me'
|
||||
# SORT_VALS[1] => 'Latency to Me',
|
||||
# }
|
||||
|
||||
HIRE_SORT_VALS = %W{ distance price_asc price_desc }
|
||||
HIRE_SORT_ORDERS = {
|
||||
|
|
@ -89,6 +93,7 @@ module JamRuby
|
|||
return @@jschema if @@jschema
|
||||
@@jschema = {
|
||||
TO_JOIN => BaseSearch.json_schema.merge({
|
||||
KEY_SORT_ORDER => self::SORT_VALS[0],
|
||||
KEY_BAND_TYPE => self::BAND_TYPE_VAL_STRS[0].to_s,
|
||||
KEY_BAND_STATUS => BAND_STATUS_VALS[0],
|
||||
KEY_PLAY_COMMIT => PLAY_COMMIT_VALS[0],
|
||||
|
|
@ -213,17 +218,13 @@ module JamRuby
|
|||
|
||||
def _sort_order(rel, filter)
|
||||
val = filter[KEY_SORT_ORDER]
|
||||
if 'distance' == val
|
||||
# locidispid = self.user.last_jam_locidispid || 0
|
||||
# my_locid = locidispid / 1000000
|
||||
# rel = rel.joins("LEFT JOIN geoiplocations AS my_geo ON my_geo.locid = #{my_locid}")
|
||||
# rel = rel.joins("LEFT JOIN geoiplocations AS other_geo ON users.last_jam_locidispid/1000000 = other_geo.locid")
|
||||
# rel = rel.group("users.id, my_geo.geog, other_geo.geog")
|
||||
# rel = rel.order('st_distance(my_geo.geog, other_geo.geog)')
|
||||
|
||||
elsif 'latency' == val
|
||||
# rel = rel.joins("LEFT JOIN current_scores ON current_scores.a_userid = users.id AND current_scores.b_userid = '#{self.user.id}'")
|
||||
# rel = rel.order('current_scores.full_score ASC')
|
||||
if 'distance' == val || val.blank?
|
||||
locidispid = self.user.last_jam_locidispid || 0
|
||||
my_locid = locidispid / 1000000
|
||||
rel = rel.joins("LEFT JOIN geoiplocations AS my_geo ON my_geo.locid = #{my_locid}")
|
||||
rel = rel.joins("LEFT JOIN geoiplocations AS other_geo ON other_geo.latitude = bands.lat AND other_geo.longitude = bands.lng")
|
||||
rel = rel.group("bands.id, my_geo.geog, other_geo.geog")
|
||||
rel = rel.order('st_distance(my_geo.geog, other_geo.geog)')
|
||||
|
||||
elsif 'price_asc' == val
|
||||
rel = rel.order('gig_minimum ASC')
|
||||
|
|
@ -231,7 +232,6 @@ module JamRuby
|
|||
elsif 'price_desc' == val
|
||||
rel = rel.order('gig_minimum DESC')
|
||||
end
|
||||
|
||||
rel
|
||||
end
|
||||
|
||||
|
|
@ -345,73 +345,82 @@ module JamRuby
|
|||
|
||||
_process_results_page(rel.all)
|
||||
end
|
||||
|
||||
def _add_description(descrip, add)
|
||||
descrip += "; " if 0 < descrip.length
|
||||
descrip + add
|
||||
end
|
||||
|
||||
def description(subtype=TO_JOIN)
|
||||
return '' if self.is_blank?(subtype)
|
||||
|
||||
filter = search_filter_for_subtype(subtype)
|
||||
str = 'Current Search: '
|
||||
|
||||
str += 'Sort = '
|
||||
case sort = filter[KEY_SORT_ORDER]
|
||||
when 'distance'
|
||||
str += SORT_ORDERS[sort]
|
||||
when 'latency'
|
||||
str += SORT_ORDERS[sort]
|
||||
when 'price_asc'
|
||||
str += HIRE_SORT_ORDERS[sort]
|
||||
when 'price_desc'
|
||||
str += HIRE_SORT_ORDERS[sort]
|
||||
end if filter.has_key?(KEY_SORT_ORDER)
|
||||
str = ''
|
||||
|
||||
if filter.has_key?(KEY_SORT_ORDER)
|
||||
str += 'Sort = '
|
||||
case sort = filter[KEY_SORT_ORDER]
|
||||
when 'distance'
|
||||
str += SORT_ORDERS[sort]
|
||||
when 'latency'
|
||||
str += SORT_ORDERS[sort]
|
||||
when 'price_asc'
|
||||
str += HIRE_SORT_ORDERS[sort]
|
||||
when 'price_desc'
|
||||
str += HIRE_SORT_ORDERS[sort]
|
||||
end
|
||||
end
|
||||
if (val = filter[KEY_BAND_TYPE]) != ANY_VAL_STR
|
||||
str += "; Band type = #{BAND_TYPES[val]}"
|
||||
str = _add_description(str, "Band type = #{BAND_TYPES[val]}")
|
||||
end if filter.has_key?(KEY_BAND_TYPE)
|
||||
|
||||
if (val = filter[KEY_BAND_STATUS]) != ANY_VAL_STR
|
||||
str += "; Band status = #{BAND_STATUS[val]}"
|
||||
str = _add_description(str, "Band status = #{BAND_STATUS[val]}")
|
||||
end if filter.has_key?(KEY_BAND_STATUS)
|
||||
|
||||
if (val = filter[KEY_PLAY_COMMIT]) != ANY_VAL_STR
|
||||
str += "; Play commitment = #{PLAY_COMMITS[val]}"
|
||||
str = _add_description(str, "Play commitment = #{PLAY_COMMITS[val]}")
|
||||
end if filter.has_key?(KEY_PLAY_COMMIT)
|
||||
|
||||
if (val = filter[KEY_TOUR_OPTION]) != ANY_VAL_STR
|
||||
str += "; Touring options = #{TOUR_OPTIONS[val]}"
|
||||
str = _add_description(str, "Touring options = #{TOUR_OPTIONS[val]}")
|
||||
end if filter.has_key?(KEY_TOUR_OPTION)
|
||||
|
||||
if (val = filter[KEY_PERF_SAMPLES]) != ANY_VAL_STR
|
||||
str += "; Performance samples = #{PERF_SAMPLES[val]}"
|
||||
str = _add_description(str, "Performance samples = #{PERF_SAMPLES[val]}")
|
||||
end if filter.has_key?(KEY_PERF_SAMPLES)
|
||||
|
||||
if (val = filter[KEY_HIRE_MAX_COST].to_i) > 0
|
||||
str += "; Maximum gig cost = $#{val}"
|
||||
str = _add_description(str, "Maximum gig cost = $#{val}")
|
||||
end if filter.has_key?(KEY_HIRE_MAX_COST)
|
||||
|
||||
if 0 < filter[KEY_HIRE_FREE]
|
||||
str += "; Bands playing free gigs"
|
||||
str = _add_description(str, "Bands playing free gigs")
|
||||
end if filter.has_key?(KEY_HIRE_FREE)
|
||||
|
||||
if (val = filter[KEY_GIGS].to_i) != GIG_COUNTS[0]
|
||||
str += "; Concert gigs = #{GIG_LABELS[val]}"
|
||||
str = _add_description(str, "Concert gigs = #{GIG_LABELS[val]}")
|
||||
end if filter.has_key?(KEY_GIGS)
|
||||
|
||||
if 0 < (val = filter[KEY_GENRES]).length
|
||||
str += "; Genres = "
|
||||
gstr = "Genres = "
|
||||
genres = Genre.where(["id IN (?)", val]).order('description').pluck(:description)
|
||||
str += genres.join(', ')
|
||||
gstr += genres.join(', ')
|
||||
str = _add_description(str, gstr)
|
||||
end if filter.has_key?(KEY_GENRES)
|
||||
|
||||
if 0 < ((val = filter[KEY_INSTRUMENTS]) || '').length
|
||||
str += "; Instruments = "
|
||||
istr = "Instruments = "
|
||||
instr_ids = val.collect { |vv| vv['instrument_id'] }
|
||||
instrs = Instrument.where(["id IN (?)", instr_ids]).order(:description)
|
||||
instrs.each_with_index do |ii, idx|
|
||||
proficiency = val.detect { |vv| vv['instrument_id'] == ii.id }['proficiency_level']
|
||||
str += "#{ii.description} (#{INSTRUMENT_PROFICIENCY[proficiency.to_i]})"
|
||||
str += ', ' unless idx==(instrs.length-1)
|
||||
istr += "#{ii.description} (#{INSTRUMENT_PROFICIENCY[proficiency.to_i]})"
|
||||
istr += ', ' unless idx==(instrs.length-1)
|
||||
end
|
||||
str = _add_description(str, istr)
|
||||
end if filter.has_key?(KEY_INSTRUMENTS)
|
||||
str = "Current Search: #{str}"
|
||||
str
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -246,6 +246,30 @@ describe 'Band Search Model' do
|
|||
|
||||
let!(:filter) { to_join }
|
||||
|
||||
it "sorts by distance" do
|
||||
bands = Band.all.reverse
|
||||
bb = bands.first
|
||||
bb.lat, bb.lng = austin_geoip[:geoiplocation].latitude, austin_geoip[:geoiplocation].longitude
|
||||
bb.save!
|
||||
bb = bands.second
|
||||
bb.lat, bb.lng = dallas_geoip[:geoiplocation].latitude, dallas_geoip[:geoiplocation].longitude
|
||||
bb.save!
|
||||
bb = bands.third
|
||||
bb.lat, bb.lng = miami_geoip[:geoiplocation].latitude, miami_geoip[:geoiplocation].longitude
|
||||
bb.save!
|
||||
bb = bands.fourth
|
||||
bb.lat, bb.lng = seattle_geoip[:geoiplocation].latitude, seattle_geoip[:geoiplocation].longitude
|
||||
bb.save!
|
||||
|
||||
filter[BandSearch::KEY_SORT_ORDER] = BandSearch::SORT_VALS[0]
|
||||
search.search_results_page(BandSearch::TO_JOIN, filter)
|
||||
expect(search.results.count).to eq(Band.count)
|
||||
expect(search.results.first.id).to eq(bands.first.id)
|
||||
expect(search.results.second.id).to eq(bands.second.id)
|
||||
expect(search.results.third.id).to eq(bands.third.id)
|
||||
expect(search.results.fourth.id).to eq(bands.fourth.id)
|
||||
end
|
||||
|
||||
it "filters by play commitment" do
|
||||
band.update_attribute(BandSearch::KEY_PLAY_COMMIT, BandSearch::PLAY_COMMIT_VALS[1].to_i)
|
||||
filter[BandSearch::KEY_PLAY_COMMIT] = BandSearch::PLAY_COMMIT_VALS[1]
|
||||
|
|
|
|||
|
|
@ -621,7 +621,7 @@ context.JK.BandSearchFilter = class BandSearchFilter extends BaseSearchFilter
|
|||
this.cancelFilter()
|
||||
|
||||
this._populateGenres()
|
||||
this._populateSortOrder()
|
||||
this._populateSortOrder() if this.isToHire()
|
||||
|
||||
switch @searchSubType
|
||||
when 'to_join' then this._populateSearchFilterToJoin()
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ if @search.is_a?(BaseSearch)
|
|||
node :name do |uu| uu.name end
|
||||
end
|
||||
|
||||
node :friend_count do |musician| @search.friend_count(musician) end
|
||||
node :follow_count do |musician| @search.follow_count(musician) end
|
||||
node :recording_count do |musician| @search.record_count(musician) end
|
||||
node :session_count do |musician| @search.session_count(musician) end
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ script#template-band-search-filter-to_join type="text/template"
|
|||
.band-search-filter-builder-top.builder-section
|
||||
.col-left
|
||||
h2 search bands
|
||||
.col-right.builder-sort-order
|
||||
.sort-order-selector
|
||||
select.easydropdown name="sort_order"
|
||||
option selected="selected" value="{sort_order}" {sort_order}
|
||||
.text-label Sort Results By:
|
||||
/ .col-right.builder-sort-order
|
||||
/ .sort-order-selector
|
||||
/ select.easydropdown name="sort_order"
|
||||
/ option selected="selected" value="{sort_order}" {sort_order}
|
||||
/ .text-label Sort Results By:
|
||||
.clearall
|
||||
|
||||
.band-search-filter-builder-middle1.builder-section
|
||||
|
|
|
|||
Loading…
Reference in New Issue