Skip to content

Commit

Permalink
Merge pull request #71 from infinity-cloud-solutions/HDBP-79-Create-U…
Browse files Browse the repository at this point in the history
…pdate-Scheduled-Orders-Endpoint

chore: fix input parse
  • Loading branch information
MarcoBurgos authored Sep 12, 2024
2 parents 07cdc30 + 6a0e484 commit 085cd26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
14 changes: 5 additions & 9 deletions src/orders/delivery/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,14 @@ def update_delivery_schedule_order(

logger.debug(f"Incoming data is {body} and {username}")

orders_with_new_sequence = UpdateScheduleRequestModel(**body)
orders_with_new_sequence = UpdateScheduleRequestModel(orders=body)

dao = OrderDAO()
reduced_orders_with_new_sequence = [
{
"id": location["id"],
"delivery_date": location["delivery_date"],
"delivery_sequence": location["delivery_sequence"],
}
for location in orders_with_new_sequence
orders_to_update = [
location.__dict__
for location in orders_with_new_sequence.orders
]
dao.bulk_update(reduced_orders_with_new_sequence)
dao.bulk_update(orders_to_update)

return doorman.build_response(
payload={"message": "scheduling updated"}, status_code=200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def update_records(self, records: List[Dict[str, Any]]) -> Dict[str, Any]:
expression_attribute_names[f"#{key}"] = key

update_expression = "SET " + ", ".join(update_expression_parts)
self.logger.info(f"Attributes Names to update {expression_attribute_names} - Attributes values to update {expression_attribute_values}")
self.logger.info(f"Attributes Names to update {expression_attribute_names} - Attributes values to update {expression_attribute_values}, with expression {update_expression}.")

self.table.update_item(
Key={"delivery_date": record["delivery_date"], "id": record["id"]},
Expand Down
4 changes: 3 additions & 1 deletion src/orders/delivery/delivery_modules/models/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ class ScheduleRequestModel(BaseModel):


class OrderModel(BaseModel):
id: int
id: StrictStr
delivery_date: StrictStr
delivery_sequence: StrictInt
driver: StrictInt
status: StrictStr


class UpdateScheduleRequestModel(BaseModel):
Expand Down

0 comments on commit 085cd26

Please sign in to comment.