An open source, non-profit web search engine
Temporarily disable startup background processes; add root domains; check for empty batches.
Daoud Clarke5e1ec9ccd545
diff --git a/mwmbl/crawler/app.py b/mwmbl/crawler/app.pyindex 431b2fa..63af8ea 100644--- a/mwmbl/crawler/app.py+++ b/mwmbl/crawler/app.py@@ -5,6 +5,7 @@ import osimport refrom datetime import datetime, timezone, timedeltafrom typing import Union+from urllib.parse import urlparsefrom uuid import uuid4import boto3@@ -61,6 +62,11 @@ def create_batch(batch: Batch):if len(batch.user_id) != USER_ID_LENGTH:raise HTTPException(400, f"User ID length is incorrect, should be {USER_ID_LENGTH} characters")+ if len(batch.items) == 0:+ return {+ 'status': 'ok',+ }+user_id_hash = _get_user_id_hash(batch)now = datetime.now(timezone.utc)@@ -123,6 +129,10 @@ def _record_urls_in_database(batch: Union[Batch, HashedBatch], user_id_hash: strif item.content is not None:found_urls |= set(item.content.links)+ parsed_urls = [urlparse(url) for url in found_urls]+ domains = {f'{p.scheme}://{p.netloc}' for p in parsed_urls}+ found_urls |= domains+if len(found_urls) > 0:url_db.user_found_urls(user_id_hash, list(found_urls), timestamp)diff --git a/mwmbl/main.py b/mwmbl/main.pyindex 5f78c09..9dadd3a 100644--- a/mwmbl/main.py+++ b/mwmbl/main.py@@ -40,10 +40,10 @@ def run():print("Creating a new index")TinyIndex.create(item_factory=Document, index_path=args.index, num_pages=NUM_PAGES, page_size=PAGE_SIZE)- Process(target=historical.run).start()- Process(target=retrieve.run).start()- Process(target=preprocess.run, args=(args.index,)).start()- Process(target=update_pages.run, args=(args.index,)).start()+ # Process(target=historical.run).start()+ # Process(target=retrieve.run).start()+ # Process(target=preprocess.run, args=(args.index,)).start()+ # Process(target=update_pages.run, args=(args.index,)).start()completer = Completer()