Skip to content

Commit 640ddc0

Browse files
committed
Fix for engagement payments not displaying in wallet
1 parent 21623d9 commit 640ddc0

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

prisma/schema.prisma

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,5 @@ enum winnings_category {
330330
enum winnings_type {
331331
PAYMENT
332332
REWARD
333-
ENGAGEMENT
334333
POINTS
335334
}

src/api/repository/winnings.repo.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ export class WinningsRepository {
6363
externalIds?: string[],
6464
date?: DateFilterType,
6565
): Prisma.winningsFindManyArgs['where'] {
66+
const typeFilter = type
67+
? {
68+
equals: type as winnings_type,
69+
}
70+
: undefined;
71+
6672
return {
6773
winner_id: winnerIds
6874
? {
@@ -79,11 +85,7 @@ export class WinningsRepository {
7985
equals: category as winnings_category,
8086
}
8187
: undefined,
82-
type: type
83-
? {
84-
equals: type as winnings_type,
85-
}
86-
: undefined,
88+
type: typeFilter,
8789
payment: status
8890
? {
8991
some: {

src/api/winnings/winnings.service.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,26 @@ export class WinningsService {
212212
return result;
213213
}
214214

215+
const isEngagementPayment =
216+
body.category === WinningsCategory.ENGAGEMENT_PAYMENT;
217+
const resolvedType = isEngagementPayment
218+
? WinningsType.PAYMENT
219+
: body.type;
220+
221+
if (isEngagementPayment && body.type !== WinningsType.PAYMENT) {
222+
this.logger.warn(
223+
'Engagement payment type overridden to PAYMENT.',
224+
{
225+
winnerId: body.winnerId,
226+
externalId: body.externalId,
227+
requestedType: body.type,
228+
},
229+
);
230+
}
231+
215232
const winningModel = {
216233
winner_id: body.winnerId,
217-
type: winnings_type[body.type],
234+
type: winnings_type[resolvedType],
218235
origin_id: originId,
219236
category: winnings_category[body.category],
220237
title: body.title,

src/dto/winning.dto.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020

2121
export enum WinningsType {
2222
PAYMENT = 'PAYMENT',
23-
ENGAGEMENT = 'ENGAGEMENT',
2423
POINTS = 'POINTS',
2524
}
2625

0 commit comments

Comments
 (0)