app/controllers/api/v1/search_controller.rb
# "Simple search" implementation: searches for the query text in all the main
# entities.
#
# Returns an array of JSON-encoded Hash objects for the specified query text, one
# for each row of Meetings, Swimmers, Teams or SwimmingPools found to be referring
# to the query text.
#
# Each returned Hash will have this structure:
#
#    {
#      class: ['Meeting'|'Swimmer'|'Team'|'SwimmingPool'|...]
#      id: [id from the retrieved model]
#      description: [get_verbose_name from the model]
#      date:  [a relevant date from the model, either updated_at or header_date for Meetings]
#    }
#
#
# === Params:
# - :query => the text to be searched using all the custom Finder instances available
#
#
# === Sample end-point usage:
#
# > curl -i -H "Accept: application/json" \
#              "http://localhost:3000/api/v1/search/simple?query=<uuencoded_query_text>&user_email=steve.alloro@whatever.com&user_token=<user_token>"
#
"Simple search" implementation: searches for the query text in all the main
entities.

Returns an array of JSON-encoded Hash objects for the specified query text, one
for each row of Meetings, Swimmers, Teams or SwimmingPools found to be referring
to the query text.

Each returned Hash will have this structure.



:query => the text to be searched using all the custom Finder instances available

Sample end-point usage.


" Simple search " implementation : searches for the query text in all the main entities . Returns an array of JSON - encoded Hash objects for the specified query text one for each row of Meetings Swimmers Teams or SwimmingPools found to be referring to the query text . Each returned Hash will have this structure . : query = > the text to be searched using all the custom Finder instances available Sample end - point usage .
def simple
    @result = []
    swimmers = get_possible_swimmers( params[:query] )
    get_possible_teams( params[:query], swimmers )
    get_possible_pools( params[:query] )
    get_possible_meetings( params[:query] )
    render status: 200, json: @result
  end
def simple @result = [ ] swimmers = get_possible_swimmers ( params [ :query ] ) get_possible_teams ( params [ :query ] , swimmers ) get_possible_pools ( params [ :query ] ) get_possible_meetings ( params [ :query ] ) render status : 200 , json : @result end
"Simple search" implementation: searches for the query text in all the main
entities.
" Simple search " implementation : searches for the query text in all the main entities .
# Get all swimmers related to the query text: # Get all teams related to the query text OR the swimmers found: # Get all swimming pools somehow related to the query text: # Get all meetings somehow related to the query text: