Skip to content

Commit

Permalink
feat: added log for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Noyan Aziz authored and Muhammad Noyan Aziz committed Nov 7, 2024
1 parent 810cb9e commit 614a5b3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions commerce_coordinator/apps/commercetools/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,9 @@ def get_orders(self, customer: CTCustomer, offset=0,
f"customer with ID {customer.id}")
order_where_clause = f"orderState=\"{order_state}\""

start_time = datetime.datetime.now()
logger.info(
"[UserOrdersView] [CommercetoolsAPIClient] - Get orders query call started at %s", datetime.datetime.now())
"[UserOrdersView] [CommercetoolsAPIClient] - Get orders query call started at %s", start_time)
values = self.base_client.orders.query(
where=["customerId=:cid", order_where_clause],
predicate_var={'cid': customer.id},
Expand All @@ -269,12 +270,22 @@ def get_orders(self, customer: CTCustomer, offset=0,
offset=offset,
expand=list(expand)
)
end_time = datetime.datetime.now()
logger.info(
"[UserOrdersView] [CommercetoolsAPIClient] - Get orders query call finished at %s",
datetime.datetime.now()
"[UserOrdersView] [CommercetoolsAPIClient] - Get orders query call finished at %s with total duration: %s",
end_time, end_time - start_time
)

return PaginatedResult(values.results, values.total, values.offset)
start_time = datetime.datetime.now()
logger.info('[UserOrdersView] [CommercetoolsAPIClient] - Pagination of CT orders started at %s',
start_time)
result = PaginatedResult(values.results, values.total, values.offset)
end_time = datetime.datetime.now()
logger.info(
'[UserOrdersView] [CommercetoolsAPIClient] - \
Pagination of CT orders finished at %s with total duration: %s', end_time, end_time - start_time)

return result

def get_orders_for_customer(self, edx_lms_user_id: int, offset=0,
limit=ORDER_HISTORY_PER_SYSTEM_REQ_LIMIT) -> (PaginatedResult[CTOrder], CTCustomer):
Expand Down

0 comments on commit 614a5b3

Please sign in to comment.