From 07d4a8103a5a5245b4b16391fb5f8ca04bddc2b0 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 22 Dec 2021 08:26:30 +0100 Subject: [PATCH] Change the query so we get only creation transactions. --- backend/src/typeorm/repository/UserTransaction.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/src/typeorm/repository/UserTransaction.ts b/backend/src/typeorm/repository/UserTransaction.ts index 87166fcfc..57f89d5a5 100644 --- a/backend/src/typeorm/repository/UserTransaction.ts +++ b/backend/src/typeorm/repository/UserTransaction.ts @@ -9,7 +9,17 @@ export class UserTransactionRepository extends Repository { limit: number, offset: number, order: Order, + onlyCreation?: boolean, ): Promise<[UserTransaction[], number]> { + if (onlyCreation) { + return this.createQueryBuilder('userTransaction') + .where('userTransaction.userId = :userId', { userId }) + .andWhere('userTransaction.type = "creation"') + .orderBy('userTransaction.balanceDate', order) + .limit(limit) + .offset(offset) + .getManyAndCount() + } return this.createQueryBuilder('userTransaction') .where('userTransaction.userId = :userId', { userId }) .orderBy('userTransaction.balanceDate', order)