From 149ac4fa8e019e3754f3f18734b1f26ca683aa34 Mon Sep 17 00:00:00 2001 From: Kylie Date: Thu, 4 Jul 2024 19:42:33 -0600 Subject: [PATCH] Fix quick search casing issue --- middleware/quick_search_query.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/middleware/quick_search_query.py b/middleware/quick_search_query.py index 4584c097..82727bdc 100644 --- a/middleware/quick_search_query.py +++ b/middleware/quick_search_query.py @@ -43,10 +43,10 @@ INNER JOIN state_names ON agencies.state_iso = state_names.state_iso WHERE - (data_sources.name LIKE '%{0}%' OR data_sources.description LIKE '%{0}%' OR data_sources.record_type LIKE '%{0}%' OR data_sources.tags LIKE '%{0}%') - AND (agencies.county_name LIKE '%{1}%' OR substr(agencies.county_name,3,length(agencies.county_name)-4) || ' County' LIKE '%{1}%' - OR agencies.state_iso LIKE '%{1}%' OR agencies.municipality LIKE '%{1}%' OR agencies.agency_type LIKE '%{1}%' OR agencies.jurisdiction_type LIKE '%{1}%' - OR agencies.name LIKE '%{1}%' OR state_names.state_name LIKE '%{1}%') + (data_sources.name ILIKE '%{0}%' OR data_sources.description ILIKE '%{0}%' OR data_sources.record_type ILIKE '%{0}%' OR data_sources.tags ILIKE '%{0}%') + AND (agencies.county_name ILIKE '%{1}%' OR substr(agencies.county_name,3,length(agencies.county_name)-4) || ' County' ILIKE '%{1}%' + OR agencies.state_iso ILIKE '%{1}%' OR agencies.municipality ILIKE '%{1}%' OR agencies.agency_type LIKE '%{1}%' OR agencies.jurisdiction_type ILIKE '%{1}%' + OR agencies.name ILIKE '%{1}%' OR state_names.state_name ILIKE '%{1}%') AND data_sources.approval_status = 'approved' AND data_sources.url_status not in ('broken', 'none found') @@ -67,7 +67,7 @@ def unaltered_search_query( :return: A list of dictionaries representing the search results. """ print(f"Query parameters: '%{search}%', '%{location}%'") - cursor.execute(QUICK_SEARCH_SQL.format(search.title(), location.title())) + cursor.execute(QUICK_SEARCH_SQL.format(search, location)) results = cursor.fetchall() return results @@ -95,7 +95,7 @@ def spacy_search_query( print(f"Query parameters: '%{depluralized_search_term}%', '%{location}%'") cursor.execute( - QUICK_SEARCH_SQL.format(depluralized_search_term.title(), location.title()) + QUICK_SEARCH_SQL.format(depluralized_search_term, location) ) results = cursor.fetchall()