Skip to content

Commit 62862dc

Browse files
ignore coupon limit checks (#153)
1 parent 3eec805 commit 62862dc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

CouponService/couponService.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ type CouponConfig = {
1818
MAX_LIMIT_CAP: number,
1919
}
2020

21-
function validateCouponData(coupon: any, couponConfig: CouponConfig): Coupon | undefined {
21+
function validateCouponData(coupon: any, couponConfig: CouponConfig, ignoreCouponLimitCheck = true): Coupon | undefined {
2222
if (
2323
coupon.id &&
2424
coupon.faucetConfigId &&
2525
coupon.maxLimitAmount > 0 &&
26-
coupon.maxLimitAmount <= couponConfig.MAX_LIMIT_CAP &&
26+
(ignoreCouponLimitCheck || coupon.maxLimitAmount <= couponConfig.MAX_LIMIT_CAP) &&
2727
coupon.consumedAmount <= coupon.maxLimitAmount &&
2828
coupon.expiry > 0
2929
) {
@@ -77,7 +77,7 @@ export class CouponService {
7777

7878
// Fetches new coupons from database into memory
7979
result?.Items?.forEach((item: Record<string, any>) => {
80-
const coupon: Coupon | undefined = validateCouponData(item, this.couponConfig)
80+
const coupon: Coupon | undefined = validateCouponData(item, this.couponConfig, true)
8181
if (coupon) {
8282
dbItemSet.add(coupon.id)
8383

@@ -114,9 +114,10 @@ export class CouponService {
114114
Key: {
115115
id: couponItem.id,
116116
},
117-
UpdateExpression: 'SET consumedAmount = :consumedAmount',
117+
UpdateExpression: 'SET consumedAmount = :consumedAmount, reset = :reset',
118118
ExpressionAttributeValues: {
119119
':consumedAmount': couponItem.consumedAmount,
120+
':reset': couponItem.reset ?? false,
120121
},
121122
}
122123

0 commit comments

Comments
 (0)