mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Change calls to have query for last three months.
This commit is contained in:
parent
735a47779f
commit
9193eeb6a8
@ -48,27 +48,41 @@ async function getUserCreations(id: number): Promise<number[]> {
|
|||||||
// userId: id,
|
// userId: id,
|
||||||
// targetDate: Raw((alias) => `${alias} > :date`, { date: "2021-09-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ }),
|
// targetDate: Raw((alias) => `${alias} > :date`, { date: "2021-09-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ }),
|
||||||
// })
|
// })
|
||||||
const findAllUserTransactionCreations = await getCustomRepository(TransactionCreationRepository)
|
const createdAmountBeforeLastMonth = await getCustomRepository(TransactionCreationRepository)
|
||||||
.createQueryBuilder('transaction_creations')
|
.createQueryBuilder('transaction_creations')
|
||||||
.select('SUM(transaction_creations.amount)', 'sum')
|
.select('SUM(transaction_creations.amount)', 'sum')
|
||||||
.where('transaction_creations.state_user_id = :id', { id })
|
.where('transaction_creations.state_user_id = :id', { id })
|
||||||
.andWhere({
|
.andWhere({
|
||||||
targetDate: Raw((alias) => `${alias} > :date and ${alias} < :enddate`, { date: "2021-09-01", enddate: "2021-10-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ })
|
targetDate: Raw((alias) => `${alias} > :date and ${alias} < :enddate`, { date: "2021-09-01", enddate: "2021-10-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ })
|
||||||
})
|
})
|
||||||
const createdAmountBeforeLastMonth = await findAllUserTransactionCreations.getRawOne()
|
.getRawOne()
|
||||||
console.log('createdAmountBeforeLastMonth', createdAmountBeforeLastMonth)
|
console.log('createdAmountBeforeLastMonth', createdAmountBeforeLastMonth)
|
||||||
|
|
||||||
const transactionCreationsLastMonthQuery = await findAllUserTransactionCreations.andWhere({
|
const createdAmountLastMonth = await getCustomRepository(TransactionCreationRepository)
|
||||||
|
.createQueryBuilder('transaction_creations')
|
||||||
|
.select('SUM(transaction_creations.amount)', 'sum')
|
||||||
|
.where('transaction_creations.state_user_id = :id', { id })
|
||||||
|
.andWhere({
|
||||||
targetDate: Raw((alias) => `${alias} > :date and ${alias} < :enddate`, { date: "2021-10-01", enddate: "2021-11-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ })
|
targetDate: Raw((alias) => `${alias} > :date and ${alias} < :enddate`, { date: "2021-10-01", enddate: "2021-11-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ })
|
||||||
})
|
})
|
||||||
const createdAmountLastMonth = await transactionCreationsLastMonthQuery.getRawOne()
|
.getRawOne()
|
||||||
console.log('createdAmountLastMonth', createdAmountLastMonth)
|
console.log('createdAmountLastMonth', createdAmountLastMonth)
|
||||||
|
|
||||||
const transactionCreationsMonthQuery = await findAllUserTransactionCreations.andWhere({
|
const createdAmountMonth = await getCustomRepository(TransactionCreationRepository)
|
||||||
|
.createQueryBuilder('transaction_creations')
|
||||||
|
.select('SUM(transaction_creations.amount)', 'sum')
|
||||||
|
.where('transaction_creations.state_user_id = :id', { id })
|
||||||
|
.andWhere({
|
||||||
targetDate: Raw((alias) => `${alias} > :date and ${alias} < :enddate`, { date: "2021-11-01", enddate: "2021-12-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ })
|
targetDate: Raw((alias) => `${alias} > :date and ${alias} < :enddate`, { date: "2021-11-01", enddate: "2021-12-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ })
|
||||||
})
|
})
|
||||||
const createdAmountMonth = await transactionCreationsMonthQuery.getRawOne()
|
.getRawOne()
|
||||||
console.log('createdAmountMonth', createdAmountMonth)
|
console.log('createdAmountMonth', createdAmountMonth)
|
||||||
|
|
||||||
|
// const transactionCreationsMonthQuery = await findAllUserTransactionCreations.andWhere({
|
||||||
|
// targetDate: Raw((alias) => `${alias} > :date and ${alias} < :enddate`, { date: "2021-11-01", enddate: "2021-12-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ })
|
||||||
|
// })
|
||||||
|
// const createdAmountMonth = await transactionCreationsMonthQuery.getRawOne()
|
||||||
|
// console.log('createdAmountMonth', createdAmountMonth)
|
||||||
// const transactionCreationsLastThreeMonth = await transactionCreationsQuery.getRawOne()
|
// const transactionCreationsLastThreeMonth = await transactionCreationsQuery.getRawOne()
|
||||||
// console.log('transactionCreations', transactionCreations)
|
// console.log('transactionCreations', transactionCreations)
|
||||||
// SELECT * FROM pending_creations WHERE userId = id
|
// SELECT * FROM pending_creations WHERE userId = id
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user