From a6443317a94aedeef4b71d405c389db12a3a7f0e Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 8 Dec 2021 13:16:17 +0100 Subject: [PATCH] Getting sum of last 3 month, not ordered by month. --- backend/src/graphql/resolver/AdminResolver.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 71a6562f2..d8c6a28b8 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -221,9 +221,9 @@ async function getUserCreations(id: number): Promise { endDate: dateNextMonth, }), }) - .groupBy('EXTRACT(MONTH FROM transaction_creations.target_date)') + .orderBy('MONTH(transaction_creations.target_date)', 'ASC') .getRawOne() - console.log('createdAmountBeforeLastMonth', createdAmountBeforeLastMonth) + console.log('createdAmountBeforeLastMonth', id, createdAmountBeforeLastMonth) const pendingCreationRepository = getCustomRepository(PendingCreationRepository) const pendingAmountBeforeLastMonth = await pendingCreationRepository @@ -236,9 +236,15 @@ async function getUserCreations(id: number): Promise { endDate: dateNextMonth, }), }) - .orderBy('EXTRACT(MONTH FROM login_pending_tasks_admin.date)') + .orderBy('MONTH(login_pending_tasks_admin.date)', 'ASC') .getRawOne() - console.log(pendingAmountBeforeLastMonth) + console.log('pendingAmountBeforeLastMonth', id, pendingAmountBeforeLastMonth) + throw new Error('Not implemented yet') + // return [ + // 1000 - usedCreationBeforeLastMonth, + // 1000 - usedCreationLastMonth, + // 1000 - usedCreationMonth, + // ] // const createdAmountLastMonth = await transactionCreationRepository // .createQueryBuilder('transaction_creations') // .select('SUM(transaction_creations.amount)', 'sum') @@ -312,7 +318,6 @@ async function getUserCreations(id: number): Promise { // 1000 - usedCreationLastMonth, // 1000 - usedCreationMonth, // ] - throw new Error('Not implemented yet') } function isCreationValid(creations: number[], amount: number, creationDate: Date) {