aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Šmerkl <46304018+SveterCZE@users.noreply.github.com>2021-04-04 17:26:08 +0200
committerPetr Šmerkl <46304018+SveterCZE@users.noreply.github.com>2021-04-04 17:26:08 +0200
commita0c18133e49455b70762bd1ee08ab8408ff03401 (patch)
tree6329502cc730d18d9165b13b5d85ef3e418bb054
parent0ae0f9aff7b1a463544bc044f9eaa80677d22b35 (diff)
downloadjustice-a0c18133e49455b70762bd1ee08ab8408ff03401.tar.gz
correct search for streets and municipalities
-rw-r--r--main.py34
1 files changed, 13 insertions, 21 deletions
diff --git a/main.py b/main.py
index 4ce0524..5a7a763 100644
--- a/main.py
+++ b/main.py
@@ -116,33 +116,25 @@ def search_results(search):
if obec_actual_or_full == "actual_results":
qry = qry.filter(Sidlo_Association.vymaz_datum == 0)
qry = qry.join(Adresy_v2, Sidlo_Association.sidlo_text)
- qry = qry.filter(Adresy_v2.obec == obec)
+ if obec_search_method == "text_anywhere":
+ qry = qry.filter(Adresy_v2.obec.contains(obec))
+ elif obec_search_method == "text_beginning":
+ qry = qry.filter(Adresy_v2.obec.like(f'{obec}%'))
+ elif obec_search_method == "text_exact":
+ qry = qry.filter(Adresy_v2.obec == obec)
if ulice:
qry = qry.join(Sidlo_Association, Company.sidlo_text)
if ulice_actual_or_full == "actual_results":
qry = qry.filter(Sidlo_Association.vymaz_datum == 0)
qry = qry.join(Adresy_v2, Sidlo_Association.sidlo_text)
- qry = qry.filter(Adresy_v2.ulice == ulice)
-
- # if obec:
- # qry = qry.join(Obce, Company.obec)
- # if obec_search_method == "text_anywhere":
- # qry = qry.filter(Obce.obec_jmeno.contains(obec))
- # elif obec_search_method == "text_beginning":
- # qry = qry.filter(Obce.obec_jmeno.like(f'{obec}%'))
- # elif obec_search_method == "text_exact":
- # qry = qry.filter(Obce.obec_jmeno == obec)
-
- # if ulice:
- # qry = qry.join(Ulice, Company.ulice)
- # if ulice_search_method == "text_anywhere":
- # qry = qry.filter(Ulice.ulice_jmeno.contains(ulice))
- # elif ulice_search_method == "text_beginning":
- # qry = qry.filter(Ulice.ulice_jmeno.like(f'{ulice}%'))
- # elif ulice_search_method == "text_exact":
- # qry = qry.filter(Ulice.ulice_jmeno == ulice)
-
+ if ulice_search_method == "text_anywhere":
+ qry = qry.filter(Adresy_v2.ulice.contains(ulice))
+ elif ulice_search_method == "text_beginning":
+ qry = qry.filter(Adresy_v2.ulice.like(f'{ulice}%'))
+ elif ulice_search_method == "text_exact":
+ qry = qry.filter(Adresy_v2.ulice == ulice)
+
if pravni_forma:
qry = qry.join(Pravni_Forma_Association_v2, Company.pravni_forma_text)
if pravni_forma_actual_or_full == "actual_results":