Skip to content

Commit

Permalink
Adjust morning delivery time (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
enrique-ayala authored Feb 22, 2024
1 parent 9cf576b commit 32a5a79
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def process_records_for_driver(self, driver_number, orders_for_today, dao):
logger.info(f"Processing records for driver {driver_number}")
morning_records = processor.select_orders_by_delivery_range_time(
order_records=orders_for_today,
delivery_time_to_match="8 AM - 1 PM",
delivery_time_to_match="9 AM - 1 PM",
driver_to_match=driver_number
)
if len(morning_records) > 0:
logger.info(f"Records to schedule for 8 AM - 1 PM delivery for Driver {driver_number}: {len(morning_records)}")
logger.info(f"Records to schedule for 9 AM - 1 PM delivery for Driver {driver_number}: {len(morning_records)}")
morning_starting_point = {
"latitude": 20.7257943,
"longitude": -103.3792193,
Expand Down
3 changes: 3 additions & 0 deletions src/orders/integration/data_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ def map_order_data(self) -> dict:
self._check_order_is_allowed()

delivery_time = self._get_note_value("Order Due Time")
if delivery_time is None or delivery_time == '8 AM - 1 PM':
delivery_time = '9 AM - 1 PM'

geolocation = {
"latitude": self._get_coordinate("latitude"),
"longitude": self._get_coordinate("longitude"),
Expand Down
8 changes: 4 additions & 4 deletions src/orders/order_modules/utils/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class DeliveryScheduler:
MORNING_DELIVERIES = "8 AM - 1 PM"
MORNING_DELIVERIES = "9 AM - 1 PM"
AFTERNOON_DELIVERIES = "1 PM - 5 PM"
AT_CAPACITY = 0
INVALID_SECTOR = 0
Expand Down Expand Up @@ -148,7 +148,7 @@ def assign_driver_for_delivery(
Arguments:
customer_location -- Geolocation data, lat and long
delivery_time -- Options can be '8 AM - 1 PM' or '1 PM - 5 PM'
delivery_time -- Options can be '9 AM - 1 PM' or '1 PM - 5 PM'
order_date -- string date with format YYYY-MM-DD
orders -- list of orders for specific date, this will help us to check capacity
source -- OrderSource Enum. Used to give priority to Shopify orders.
Expand All @@ -160,11 +160,11 @@ def assign_driver_for_delivery(
Notes:
Sector-Based Delivery Preferences for HiberryApp orders:
- West Sectors (1 and 2):
- Deliveries are preferred on Mondays, Wednesdays, and Fridays (days 0, 2, 4) during the morning (8 AM - 1 PM).
- Deliveries are preferred on Mondays, Wednesdays, and Fridays (days 0, 2, 4) during the morning (9 AM - 1 PM).
- Deliveries are preferred on Tuesdays, Thursdays, and Saturdays (days 1, 3, 5) during the afternoon (1 PM - 5 PM).
- East Sectors (3 and 4):
- Deliveries are preferred on Mondays, Wednesdays, and Fridays (days 0, 2, 4) during the afternoon (1 PM - 5 PM).
- Deliveries are preferred on Tuesdays, Thursdays, and Saturdays (days 1, 3, 5) during the morning (8 AM - 1 PM).
- Deliveries are preferred on Tuesdays, Thursdays, and Saturdays (days 1, 3, 5) during the morning (9 AM - 1 PM).
"""
day_of_week = self._get_day_of_week(order_date)
customer_sector = self._get_customer_sector(customer_location)
Expand Down
2 changes: 1 addition & 1 deletion tests/deliveries/test_delivery_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def setUp(self):
self.southeast_location = (20.595247, -103.315226)
self.monday = "2024-01-08"
self.tuesday = "2024-01-09"
self.morning_time = "8 AM - 1 PM"
self.morning_time = "9 AM - 1 PM"
self.afternoon_time = "1 PM - 5 PM"

def test_give_a_request_for_northwest_sector_for_the_morning_route_on_a_monday_order_will_be_created(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_shopify_data_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_map_order_data(self):
"delivery_address": "123 Happy St",
"geolocation": {"latitude": 20.0,"longitude": -105.0},
"delivery_date": "2023-12-20",
"delivery_time": "8 AM - 1 PM",
"delivery_time": "9 AM - 1 PM",
"cart_items": [{"product": "Product 1", "price": 100.0 ,"quantity": 2}],
"total_amount": 200.0,
"payment_method": 'PAID',
Expand Down

0 comments on commit 32a5a79

Please sign in to comment.