From 2d63b4bc1158f30adb00904816a32260e5ada036 Mon Sep 17 00:00:00 2001 From: MartinMikita Date: Sat, 12 May 2018 11:59:53 +0200 Subject: [PATCH] Fixed typo of missing domain_id and order of commands. --- web/websearch.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web/websearch.py b/web/websearch.py index 5e01f2e..c2ad886 100755 --- a/web/websearch.py +++ b/web/websearch.py @@ -33,12 +33,19 @@ raise Exception('Missing required environment variable DOMAINS!') sys.exit(1) + +def get_domain_id(domain): + # Remove unexpected characters: .:/-, + return domain.replace('.', '').replace(':', '').replace('/', '').replace('-', '').replace(',', '') + + # Split domains by comma and prepare source/index for this domain: # Input data /data//search.tsv # Prepare domain IDs domains = domains.split(',') domain_ids = {} for domain in domains: + domain_id = get_domain_id(domain) # Check uniqueness and skip duplicates if domain_id in domain_ids.values(): continue @@ -54,11 +61,6 @@ SEARCH_DEFAULT_COUNT = int(getenv('SEARCH_DEFAULT_COUNT')) -def get_domain_id(domain): - # Remove unexpected characters: .:/-, - return domain.replace('.', '').replace(':', '').replace('/', '').replace('-', '').replace(',', '') - - # --------------------------------------------------------- """ Process query to Sphinx searchd