enable commented out lines (added for debugging)

This commit is contained in:
Nuwan 2022-02-08 21:06:22 +05:30
parent 3f5cceb031
commit bffab7564d
2 changed files with 139 additions and 236 deletions

View File

@ -95,103 +95,6 @@ class ApiSearchController < ApiController
end
end
#Filter users by first fetching users from latency graph database
#for latency specific filter options and then query the postgresql relational
#database for other filter options
# def filter
# page = [params[:page].to_i, 1].max
# limit = 20
# filter_params = {}
# filter_params.merge!(from_location: params[:from_location] ? '1' : '0')
# genres = params[:genres]
# if genres && genres.any?
# genres.map!{|genre| {id: genre} }
# filter_params.merge!(genres: genres)
# end
# beginner = ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:proficiency_beginner])
# intermediate = ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:proficiency_intermediate])
# expert = ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:proficiency_expert])
# proficiency_levels = []
# proficiency_levels.push(1) if beginner
# proficiency_levels.push(2) if intermediate
# proficiency_levels.push(3) if expert
# instruments = params[:instruments]
# if instruments && instruments.any?
# inst = []
# instruments.each do |ii|
# proficiency_levels.each do |pl|
# inst << { instrument_id: ii, proficiency_level: pl}
# end
# end
# filter_params.merge!(instruments: inst)
# end
# filter_params.merge!(joined_within_days: params[:joined_within_days]) unless params[:joined_within_days].blank?
# filter_params.merge!(active_within_days: params[:active_within_days]) unless params[:active_within_days].blank?
# latency_good = ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:latency_good])
# latency_fair = ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:latency_fair])
# latency_high = ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:latency_high])
# @latency_data = []
# #begin
# #bm = Benchmark.measure do
# @latency_data = users_latency_data(latency_good, latency_fair, latency_high, filter_params, page, limit)
# user_ids = @latency_data.map{ |l_data| l_data[:user_id] }
# user_ids = User.musicians.limit(3).map(&:id)
# #end
# # Bugsnag.notify("search_users_benchmark") do |report|
# # report.severity = "info"
# # report.add_tab(:benchmark, benchmark: bm.to_s)
# # end if Rails.env.production?
# # filter_params = {
# # "sort_order"=>"latency",
# # "instruments"=>[],
# # "genres"=> [],
# # "concert_gigs"=>"-1",
# # "interests"=>"any",
# # "studio_sessions"=>"-1",
# # "ages"=>[],
# # "skill_level"=>"-1",
# # "joined_within_days"=>"-1",
# # "active_within_days"=>"-1",
# # "from_location" => "0",
# # }
# sobj = MusicianSearch.user_search_filter(current_user)
# #debugger
# @search = sobj.search_results_page(filter_params, page, limit, user_ids)
# respond_with @search, responder: ApiResponder, status: 201, template: 'api_search/index'
# # rescue => exception
# # logger.debug("Latency exception: #{exception.message}")
# # Bugsnag.notify(exception) do |report|
# # report.severity = "error"
# # report.add_tab(:latency, {
# params: params,
# user_id: current_user.id,
# name: current_user.name,
# url: filter_latency_url,
# })
# end
# render json: {}, status: 500
# end
#end
def filter
latency_good = ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:latency_good])

View File

@ -15,13 +15,13 @@ if @search.is_a?(BaseSearch)
end
if @search.is_a? MusicianSearch
# node :description do |foo|
# @search.description
# end
node :description do |foo|
@search.description
end
# node :is_blank_filter do |foo|
# @search.is_blank?
# end
node :is_blank_filter do |foo|
@search.is_blank?
end
child(:results => :musicians) {
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :online, :musician, :photo_url, :biography, :regionname, :score, :full_score
@ -85,181 +85,181 @@ if @search.is_a?(BaseSearch)
elsif @search.is_a?(BandSearch)
# node :is_blank_filter do |foo|
# @search.is_blank?(params[:subtype])
# end
node :is_blank_filter do |foo|
@search.is_blank?(params[:subtype])
end
# node :description do |foo|
# @search.description(params[:subtype])
# end
node :description do |foo|
@search.description(params[:subtype])
end
# child(:results => :bands) {
# attributes :id, :name, :city, :state, :country, :photo_url, :biography, :logo_url, :website
child(:results => :bands) {
attributes :id, :name, :city, :state, :country, :photo_url, :biography, :logo_url, :website
# node :is_following do |band|
# @search.is_follower?(band)
# end
node :is_following do |band|
@search.is_follower?(band)
end
# node :biography do |band|
# band.biography.nil? ? "" : band.biography
# end
node :biography do |band|
band.biography.nil? ? "" : band.biography
end
# child :genres => :genres do
# attributes :genre_id, :description
# end
child :genres => :genres do
attributes :genre_id, :description
end
# child :users => :players do |pl|
# node :user_id do |uu| uu.id end
# node :photo_url do |uu| uu.photo_url end
# node :name do |uu| uu.name end
# node :instruments do |uu| uu.instruments.map(&:id).join(',') end
# end
child :users => :players do |pl|
node :user_id do |uu| uu.id end
node :photo_url do |uu| uu.photo_url end
node :name do |uu| uu.name end
node :instruments do |uu| uu.instruments.map(&:id).join(',') end
end
# node :follow_count do |band| @search.follow_count(band) end
# node :recording_count do |band| @search.record_count(band) end
# node :session_count do |band| @search.session_count(band) end
# }
node :follow_count do |band| @search.follow_count(band) end
node :recording_count do |band| @search.record_count(band) end
node :session_count do |band| @search.session_count(band) end
}
end
else
node :search_type do |ss| ss.search_type end
# if @search.session_invite_search?
# child(:results => :suggestions) {
# node :value do |uu| uu.name end
# node :data do |uu| uu.id end
# }
# end
if @search.session_invite_search?
child(:results => :suggestions) {
node :value do |uu| uu.name end
node :data do |uu| uu.id end
}
end
# if @search.bands_text_search?
# child(:results => :bands) {
# attributes :id, :name, :location, :photo_url, :logo_url, :website
# }
# end
if @search.bands_text_search?
child(:results => :bands) {
attributes :id, :name, :location, :photo_url, :logo_url, :website
}
end
# if @search.musicians_text_search?
# child(:results => :musicians) {
# attributes :id, :first_name, :last_name, :name, :location, :photo_url
if @search.musicians_text_search?
child(:results => :musicians) {
attributes :id, :first_name, :last_name, :name, :location, :photo_url
# node :is_friend do |musician|
# musician.friends?(current_user)
# end
node :is_friend do |musician|
musician.friends?(current_user)
end
# node :pending_friend_request do |musician|
# musician.pending_friend_request?(current_user)
# end
node :pending_friend_request do |musician|
musician.pending_friend_request?(current_user)
end
# child :musician_instruments => :instruments do
# attributes :instrument_id, :description, :proficiency_level, :priority
# end
# }
# end
child :musician_instruments => :instruments do
attributes :instrument_id, :description, :proficiency_level, :priority
end
}
end
# if @search.musicians_filter_search?
if @search.musicians_filter_search?
# node :page_count do |foo|
# @search.page_count
# end
node :page_count do |foo|
@search.page_count
end
# node :my_audio_latency do |user|
# current_user.last_jam_audio_latency.round if current_user.last_jam_audio_latency
# end
node :my_audio_latency do |user|
current_user.last_jam_audio_latency.round if current_user.last_jam_audio_latency
end
# node :is_blank_filter do |foo|
# @search.is_blank?
# end
node :is_blank_filter do |foo|
@search.is_blank?
end
# node :filter_json do |foo|
# @search.to_json
# end
node :filter_json do |foo|
@search.to_json
end
# child(:results => :musicians) {
# attributes :id, :first_name, :last_name, :name, :city, :state, :country, :online, :musician, :photo_url, :biography, :regionname, :score, :full_score
child(:results => :musicians) {
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :online, :musician, :photo_url, :biography, :regionname, :score, :full_score
# node :is_friend do |musician|
# @search.is_friend?(musician)
# end
node :is_friend do |musician|
@search.is_friend?(musician)
end
# node :is_following do |musician|
# @search.is_follower?(musician)
# end
node :is_following do |musician|
@search.is_follower?(musician)
end
# node :pending_friend_request do |musician|
# musician.pending_friend_request?(current_user)
# end
node :pending_friend_request do |musician|
musician.pending_friend_request?(current_user)
end
# node :biography do |musician|
# musician.biography.nil? ? "" : musician.biography
# end
node :biography do |musician|
musician.biography.nil? ? "" : musician.biography
end
# child :musician_instruments => :instruments do
# attributes :instrument_id, :description, :proficiency_level, :priority
# end
child :musician_instruments => :instruments do
attributes :instrument_id, :description, :proficiency_level, :priority
end
# child :top_followings => :followings do |uf|
# node :user_id do |uu| uu.id end
# node :photo_url do |uu| uu.photo_url end
# node :name do |uu| uu.name end
# end
child :top_followings => :followings do |uf|
node :user_id do |uu| uu.id end
node :photo_url do |uu| uu.photo_url end
node :name do |uu| uu.name end
end
# node :follow_count do |musician| @search.follow_count(musician) end
# node :friend_count do |musician| @search.friend_count(musician) end
# node :recording_count do |musician| @search.record_count(musician) end
# node :session_count do |musician| @search.session_count(musician) end
node :follow_count do |musician| @search.follow_count(musician) end
node :friend_count do |musician| @search.friend_count(musician) end
node :recording_count do |musician| @search.record_count(musician) end
node :session_count do |musician| @search.session_count(musician) end
# node :audio_latency do |musician|
# last_jam_audio_latency(musician)
# end
# }
# end
node :audio_latency do |musician|
last_jam_audio_latency(musician)
end
}
end
# if @search.bands_filter_search?
if @search.bands_filter_search?
# node :page_count do |foo|
# @search.page_count
# end
node :page_count do |foo|
@search.page_count
end
# child(:results => :bands) {
# attributes :id, :name, :city, :state, :country, :photo_url, :biography, :logo_url, :website
child(:results => :bands) {
attributes :id, :name, :city, :state, :country, :photo_url, :biography, :logo_url, :website
# node :is_following do |band|
# @search.is_follower?(band)
# end
node :is_following do |band|
@search.is_follower?(band)
end
# node :biography do |band|
# band.biography.nil? ? "" : band.biography
# end
node :biography do |band|
band.biography.nil? ? "" : band.biography
end
# child :genres => :genres do
# attributes :genre_id, :description
# end
child :genres => :genres do
attributes :genre_id, :description
end
# child :users => :players do |pl|
# node :user_id do |uu| uu.id end
# node :photo_url do |uu| uu.photo_url end
# node :name do |uu| uu.name end
# node :instruments do |uu| uu.instruments.map(&:id).join(',') end
# end
child :users => :players do |pl|
node :user_id do |uu| uu.id end
node :photo_url do |uu| uu.photo_url end
node :name do |uu| uu.name end
node :instruments do |uu| uu.instruments.map(&:id).join(',') end
end
# node :follow_count do |band| @search.follow_count(band) end
# node :recording_count do |band| @search.record_count(band) end
# node :session_count do |band| @search.session_count(band) end
# }
# end
node :follow_count do |band| @search.follow_count(band) end
node :recording_count do |band| @search.record_count(band) end
node :session_count do |band| @search.session_count(band) end
}
end
# if @search.fans_text_search?
# child(:results => :fans) {
# attributes :id, :first_name, :last_name, :name, :location, :photo_url
if @search.fans_text_search?
child(:results => :fans) {
attributes :id, :first_name, :last_name, :name, :location, :photo_url
# node :is_friend do |fan|
# fan.friends?(current_user)
# end
node :is_friend do |fan|
fan.friends?(current_user)
end
# node :pending_friend_request do |fan|
# fan.pending_friend_request?(current_user)
# end
# }
# end
node :pending_friend_request do |fan|
fan.pending_friend_request?(current_user)
end
}
end
end