diff --git a/db.py b/db.py index d8b134e..0a6a055 100644 --- a/db.py +++ b/db.py @@ -14,6 +14,3 @@ def __init__(self, connection_string=os.environ.get("MONGODB_URI")): @property def database(self): return self.db - - def close_connection(self): - self.client.close() diff --git a/update_cars.py b/update_cars.py index 5af7bbe..b340418 100644 --- a/update_cars.py +++ b/update_cars.py @@ -15,21 +15,17 @@ async def main(): db = MongoDBConnection().database collection = db[collection_name] + + # Create indexes collection.create_index({"month": 1, "make": 1}); collection.create_index({"make": 1}); collection.create_index({"fuel_type": 1}); collection.create_index({"make": 1, "fuel_type": 1}); collection.create_index({"number": 1}); - db.client.close() - response = await updater.main( - collection_name=collection_name, - zip_url=zip_url, - zip_file_name=zip_file_name, - key_fields=key_fields, - ) + db.client.close() - return response + return await updater.main(collection_name, zip_file_name, zip_url, key_fields) def handler(event, context): diff --git a/update_coe.py b/update_coe.py index 53ff42d..04c9232 100644 --- a/update_coe.py +++ b/update_coe.py @@ -15,21 +15,17 @@ async def main(): db = MongoDBConnection().database collection = db[collection_name] + + # Create indexes collection.create_index({"month": 1, "vehicle_class": 1}); collection.create_index({"vehicle_class": 1}); collection.create_index({"month": 1, "bidding_no": 1}); collection.create_index({"premium": 1}); collection.create_index({"bids_success": 1, "bids_received": 1}); - db.client.close() - response = await updater.main( - collection_name=collection_name, - zip_url=zip_url, - zip_file_name=zip_file_name, - key_fields=key_fields, - ) + db.client.close() - return response + return await updater.main(collection_name, zip_file_name, zip_url, key_fields) def handler(event, context): diff --git a/updater.py b/updater.py index 30670ec..00bd2d4 100644 --- a/updater.py +++ b/updater.py @@ -18,8 +18,6 @@ async def updater( collection_name: str, zip_file_name: str, zip_url: str, key_fields: List[str] ) -> str: - # client = MongoClient(os.environ.get("MONGODB_URI")) - # db = client[os.environ.get("MONGODB_DB_NAME")] db = MongoDBConnection().database collection = db[collection_name]