Skip to content

Commit

Permalink
Add option to make query barray from request params
Browse files Browse the repository at this point in the history
This will be useful in map embeds
  • Loading branch information
ffont committed Feb 7, 2024
1 parent 2c13e12 commit eafe53f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion geotags/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,16 @@ def geotag_for_sound_barray(request, sound_id):

def geotags_for_query_barray(request):
results_cache_key = request.GET.get('key', None)
results_docs = cache.get(results_cache_key)
if results_cache_key is not None:
# If cache key is present, use it to get the results
results_docs = cache.get(results_cache_key)
else:
# Otherwise, perform a search query to get the results
query_params, _, _ = search_prepare_parameters(request)
update_query_params_for_map_query(query_params)
results, _ = perform_search_engine_query(query_params)
results_docs = results.docs

generated_bytearray, num_geotags = generate_bytearray(results_docs)
if num_geotags > 0:
log_map_load('query', num_geotags, request)
Expand Down

0 comments on commit eafe53f

Please sign in to comment.