Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Ru Chern Chong committed May 24, 2024
1 parent bb57ab2 commit ee259cb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
3 changes: 0 additions & 3 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 4 additions & 8 deletions update_cars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 4 additions & 8 deletions update_coe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit ee259cb

Please sign in to comment.