mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Change query to query builder.
This commit is contained in:
parent
13b533b1e2
commit
6a152a8791
@ -44,10 +44,14 @@ export class AdminResolver {
|
||||
|
||||
async function getUserCreations(id: number): Promise<number[]> {
|
||||
// TODO: NOW()-ActualDays - 2 Monate
|
||||
const transactionCreations = await getCustomRepository(TransactionCreationRepository).find({
|
||||
userId: id,
|
||||
targetDate: Raw((alias) => `${alias} > :date`, { date: "2021-09-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ }),
|
||||
})
|
||||
// const transactionCreations = await getCustomRepository(TransactionCreationRepository).find({
|
||||
// userId: id,
|
||||
// targetDate: Raw((alias) => `${alias} > :date`, { date: "2021-09-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ }),
|
||||
// })
|
||||
const transactionCreations = await getCustomRepository(TransactionCreationRepository)
|
||||
.createQueryBuilder()
|
||||
.select(['SUM(login_pending_tasks_admin.amount)'])
|
||||
.where('login_pending_tasks_admin.userId = :id', { id })
|
||||
console.log('transactionCreations', transactionCreations)
|
||||
// SELECT * FROM pending_creations WHERE userId = id
|
||||
const pendingCreations = await getCustomRepository(PendingCreationRepository).find({
|
||||
@ -55,6 +59,12 @@ async function getUserCreations(id: number): Promise<number[]> {
|
||||
date: Raw((alias) => `${alias} > :date`, { date: "2021-09-01" /* TODO: NOW().format("YYYY-MM") + '-01' - 2 Month */ }),
|
||||
})
|
||||
console.log('pendingCreations', pendingCreations)
|
||||
// const createdAmountBeforeLastMonth = transactionCreations.forEach(element => {
|
||||
// element.targetDate
|
||||
// })
|
||||
// const createdAmountLastMonth = ...
|
||||
// const createdAmountCurrentMonth = ...
|
||||
|
||||
// COUNT amount from 2 tables
|
||||
// if amount < 3000 => Store in pending_creations
|
||||
return [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user