Skip to content

Commit 9accc4a

Browse files
authored
Merge pull request #473 from Merit-Systems/br/exclude_pending_credits
Exclude Pending Credits
2 parents 45f9d46 + 18125b8 commit 9accc4a

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

  • packages/app/control/src/services/db/payments

‎packages/app/control/src/services/db/payments/list.ts‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,39 @@ async function listPayments(
4848
{ page, page_size }: PaginationParams
4949
) {
5050
const skip = page * page_size;
51+
const fiveHoursAgo = new Date(Date.now() - 5 * 60 * 60 * 1000);
52+
53+
// Add filter to exclude pending payments older than 5 hours
54+
const enhancedWhere: Prisma.PaymentWhereInput = {
55+
...where,
56+
OR: [
57+
// Include all non-pending payments
58+
{
59+
status: {
60+
not: 'pending',
61+
},
62+
},
63+
// Include pending payments that are less than 5 hours old
64+
{
65+
status: 'pending',
66+
createdAt: {
67+
gte: fiveHoursAgo,
68+
},
69+
},
70+
],
71+
};
5172

5273
const [payments, totalCount] = await Promise.all([
5374
db.payment.findMany({
54-
where,
75+
where: enhancedWhere,
5576
orderBy: {
5677
createdAt: 'desc',
5778
},
5879
skip,
5980
take: page_size,
6081
}),
6182
db.payment.count({
62-
where,
83+
where: enhancedWhere,
6384
}),
6485
]);
6586

0 commit comments

Comments
 (0)