mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Remove QueryBuilder and rewrite it with ContributionEntity.findAndCount method.
This commit is contained in:
parent
a15b3265de
commit
3476f680ed
@ -431,25 +431,18 @@ export class ContributionResolver {
|
|||||||
@Arg('statusFilter', () => [ContributionStatus], { nullable: true })
|
@Arg('statusFilter', () => [ContributionStatus], { nullable: true })
|
||||||
statusFilter?: ContributionStatus[],
|
statusFilter?: ContributionStatus[],
|
||||||
): Promise<ContributionListResult> {
|
): Promise<ContributionListResult> {
|
||||||
const where: {
|
const [dbContributions, count] = await DbContribution.findAndCount({
|
||||||
contributionStatus?: FindOperator<string> | null
|
where: {
|
||||||
} = {}
|
...(statusFilter && statusFilter.length && { contributionStatus: In(statusFilter) }),
|
||||||
|
},
|
||||||
if (statusFilter && statusFilter.length) {
|
withDeleted: true,
|
||||||
where.contributionStatus = In(statusFilter)
|
order: {
|
||||||
}
|
createdAt: order,
|
||||||
|
},
|
||||||
const [dbContributions, count] = await getConnection()
|
relations: ['user'],
|
||||||
.createQueryBuilder()
|
skip: (currentPage - 1) * pageSize,
|
||||||
.select('c')
|
take: pageSize,
|
||||||
.from(DbContribution, 'c')
|
})
|
||||||
.innerJoinAndSelect('c.user', 'u')
|
|
||||||
.where(where)
|
|
||||||
.withDeleted()
|
|
||||||
.orderBy('c.createdAt', order)
|
|
||||||
.limit(pageSize)
|
|
||||||
.offset((currentPage - 1) * pageSize)
|
|
||||||
.getManyAndCount()
|
|
||||||
|
|
||||||
return new ContributionListResult(
|
return new ContributionListResult(
|
||||||
count,
|
count,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user