Skip to content

Commit 7fc95c3

Browse files
committed
fix: pre-commit format
1 parent ecf82d7 commit 7fc95c3

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

backend/repository/discount_repository.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ def delete_discount(self, discount_entry: Discount) -> Tuple[HTTPStatus, str]:
247247
message = f'Failed to delete discount data: {str(e)}'
248248
logger.error(f'[{discount_entry.rangeKey}] {message}')
249249
return HTTPStatus.INTERNAL_SERVER_ERROR, message
250-
250+
251251
def append_claim_discount(self, discount_entry: Discount, append_count: int = 1):
252252
"""
253253
Adds to the discountUses attribute and decreases remainingUses
254-
254+
255255
:param discount_entry: Discount object to be updated.
256256
:type discount_entry: Discount
257257
:param append_count: The count to be appended.
@@ -263,19 +263,19 @@ def append_claim_discount(self, discount_entry: Discount, append_count: int = 1)
263263
# Check if there are remaining uses available
264264
if discount_entry.remainingUses is not None and discount_entry.remainingUses <= 0:
265265
return HTTPStatus.BAD_REQUEST, None, 'No remaining uses available for this discount'
266-
266+
267267
with TransactWrite(connection=self.conn) as transaction:
268-
actions = [
269-
Discount.currentDiscountUses.add(append_count),
270-
Discount.remainingUses.add(-append_count)
271-
]
268+
actions = [Discount.currentDiscountUses.add(append_count), Discount.remainingUses.add(-append_count)]
272269
transaction.update(discount_entry, actions=actions)
273-
270+
274271
discount_entry.refresh()
275-
276-
logger.info(f'[{discount_entry.rangeKey}] Update discount uses successful. 'f'Uses: {discount_entry.currentDiscountUses}, Remaining: {discount_entry.remainingUses}')
272+
273+
logger.info(
274+
f'[{discount_entry.rangeKey}] Update discount uses successful. '
275+
f'Uses: {discount_entry.currentDiscountUses}, Remaining: {discount_entry.remainingUses}'
276+
)
277277
return HTTPStatus.OK, discount_entry, ''
278-
278+
279279
except TransactWriteError as e:
280280
message = f'Failed to update discount uses: {str(e)}'
281281
logger.error(f'[{discount_entry.rangeKey}] {message}')

backend/usecase/discount_usecase.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ def claim_discount(self, event_id: str, entry_id: str, registration_id: str):
137137
)
138138

139139
discount_data = self.__convert_data_entry_to_dict(discount_entry)
140-
140+
141141
# reusable discount code
142142
if discount_entry.isReusable:
143-
if (discount_entry.maxDiscountUses is not None and
144-
discount_entry.remainingUses is not None and
145-
discount_entry.remainingUses <= 0):
143+
if (
144+
discount_entry.maxDiscountUses is not None
145+
and discount_entry.remainingUses is not None
146+
and discount_entry.remainingUses <= 0
147+
):
146148
return JSONResponse(
147149
status_code=HTTPStatus.BAD_REQUEST,
148150
content={'message': 'Discount has no remaining uses'},

0 commit comments

Comments
 (0)