VRFS-3389 fetch genres/instrumnets only with jamtracks; initial search impl
This commit is contained in:
parent
077b5a700d
commit
10d4d99953
|
|
@ -22,5 +22,12 @@ module JamRuby
|
|||
def to_s
|
||||
description
|
||||
end
|
||||
|
||||
def self.jam_track_list
|
||||
sql = "SELECT DISTINCT genre_id FROM jam_tracks WHERE genre_id IS NOT NULL"
|
||||
Genre.where("genres.id IN (#{sql})")
|
||||
.order('genres.description ASC')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ module JamRuby
|
|||
return Instrument.where('instruments.popularity > 0').order('instruments.popularity DESC, instruments.description ASC')
|
||||
end
|
||||
|
||||
def self.jam_track_list
|
||||
sql = "SELECT DISTINCT instrument_id FROM jam_track_tracks WHERE instrument_id IS NOT NULL"
|
||||
Instrument.where("instruments.id IN (#{sql})")
|
||||
.order('instruments.description ASC')
|
||||
end
|
||||
|
||||
def icon_name
|
||||
MAP_ICON_NAME[self.id]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ class ApiGenresController < ApiController
|
|||
respond_to :json
|
||||
|
||||
def index
|
||||
@genres = Genre.order(:description)
|
||||
if params[:jamtracks]
|
||||
@genres = Genre.jam_track_list
|
||||
else
|
||||
@genres = Genre.order(:description)
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ class ApiInstrumentsController < ApiController
|
|||
respond_to :json
|
||||
|
||||
def index
|
||||
@instruments = Instrument.standard_list
|
||||
if params[:jamtracks]
|
||||
@instruments = Instrument.jam_track_list
|
||||
else
|
||||
@instruments = Instrument.standard_list
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
|||
|
|
@ -66,4 +66,30 @@ class ApiSearchController < ApiController
|
|||
end
|
||||
end
|
||||
|
||||
def jam_tracks
|
||||
if request.get?
|
||||
if params[:results]
|
||||
@search = JamTrackSearch.user_search_filter(current_user).search_results_page(params[:subtype])
|
||||
respond_with @search, responder: ApiResponder, status: 201, template: 'api_search/index'
|
||||
elsif params[:genres]
|
||||
|
||||
elsif params[:instruments]
|
||||
|
||||
else
|
||||
render :json => JamTrackSearch.search_filter_json(current_user, params[:subtype]), :status => 200
|
||||
end
|
||||
|
||||
elsif request.post?
|
||||
sobj = JamTrackSearch.user_search_filter(current_user)
|
||||
filter = params[:filter]
|
||||
if filter == 'reset'
|
||||
@search = sobj.reset_search_results(params[:subtype])
|
||||
else
|
||||
json = JSON.parse(filter, :create_additions => false)
|
||||
@search = sobj.search_results_page(params[:subtype], json, [params[:page].to_i, 1].max)
|
||||
end
|
||||
respond_with @search, responder: ApiResponder, status: 201, template: 'api_search/index'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -496,6 +496,7 @@ SampleApp::Application.routes.draw do
|
|||
match '/search' => 'api_search#index', :via => :get
|
||||
match '/search/musicians' => 'api_search#musicians', :via => [:get, :post]
|
||||
match '/search/bands' => 'api_search#bands', :via => [:get, :post]
|
||||
match '/search/jam_tracks' => 'api_search#jam_tracks', :via => [:get, :post]
|
||||
|
||||
# join requests
|
||||
match '/join_requests/:id' => 'api_join_requests#show', :via => :get, :as => 'api_join_request_detail'
|
||||
|
|
|
|||
Loading…
Reference in New Issue