@@ -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 } ' )
0 commit comments