Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional logs for schedule-orders #62

Merged
merged 4 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/orders_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ on:
push:
paths:
- 'src/orders/**'
- '.github/workflows/orders_pipeline.yaml'
branches:
- 'main'
- 'feature**'
- 'feature*'
workflow_dispatch:
jobs:
run_unit_tests:
Expand All @@ -28,12 +27,11 @@ jobs:
working-directory: ./tests

development:
if: startsWith(github.event.ref, 'refs/heads/main')
uses: ./.github/workflows/pipeline_template.yaml
needs: [run_unit_tests]
with:
stack_name: ${{ vars.ORDERS_STACK_NAME }}-development
sam_deploy_overrides: "ShopifyEventBusName=${{ vars.SHOPIFY_EVENT_BUS_NAME_DEV }} StageName=development"
sam_deploy_overrides: "ShopifyEventBusName=${{ vars.SHOPIFY_EVENT_BUS_NAME_DEV }} StageName=development LogLevel=DEBUG"
sam_template: src/orders/template.yaml
aws_region: us-east-1
pipeline_execution_role: ${{ vars.PIPELINE_EXECUTION_ROLE_DEV }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ def update_records(self, records: List[Dict[str, Any]]) -> Dict[str, Any]:
:rtype: Dict[str, Any]
"""
try:
for record in records:
total_records = len(records)
self.logger.debug(f"Total records to update: {total_records}")
for index, record in enumerate(records, start=1):
self.logger.debug(f"Updating record {index} of {total_records}")

update_expression = "SET delivery_sequence = :val, #status = :statusVal, #driver = :driverVal"
expression_attribute_values = {
":val": record["delivery_sequence"],
Expand Down
3 changes: 3 additions & 0 deletions src/orders/delivery/location_router.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from itertools import permutations
from math import inf
from aws_lambda_powertools import Logger


class TravelPlanner:
Expand Down Expand Up @@ -30,6 +31,7 @@ def find_shortest_path(self, locations, start_point):
locations.append(start_point)
num_locations = len(locations)
locations_indices = list(range(num_locations))
logger = Logger()

start_index = next(
(
Expand Down Expand Up @@ -62,6 +64,7 @@ def find_shortest_path(self, locations, start_point):
order["delivery_sequence"] = index
# We need to remove starting point from the list, so there is no confusions in frontend
ordered_locations.pop(0)
logger.debug("Shortest path found.")
return ordered_locations
else:
raise ValueError("Start point not found in locations list")
Loading