mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Withdrew where clause to an variable with inline condition.
This commit is contained in:
parent
a2eccb12ed
commit
ae52b520dd
@ -48,31 +48,22 @@ export class ContributionResolver {
|
||||
@Ctx() context: Context,
|
||||
): Promise<Contribution[]> {
|
||||
const user = getUser(context)
|
||||
let contributions
|
||||
if (filterConfirmed) {
|
||||
contributions = await dbContribution.find({
|
||||
where: {
|
||||
const where = filterConfirmed
|
||||
? {
|
||||
userId: user.id,
|
||||
confirmedBy: IsNull(),
|
||||
},
|
||||
order: {
|
||||
createdAt: order,
|
||||
},
|
||||
skip: (currentPage - 1) * pageSize,
|
||||
take: pageSize,
|
||||
})
|
||||
} else {
|
||||
contributions = await dbContribution.find({
|
||||
where: {
|
||||
}
|
||||
: {
|
||||
userId: user.id,
|
||||
},
|
||||
order: {
|
||||
createdAt: order,
|
||||
},
|
||||
skip: (currentPage - 1) * pageSize,
|
||||
take: pageSize,
|
||||
})
|
||||
}
|
||||
}
|
||||
const contributions = await dbContribution.find({
|
||||
where,
|
||||
order: {
|
||||
createdAt: order,
|
||||
},
|
||||
skip: (currentPage - 1) * pageSize,
|
||||
take: pageSize,
|
||||
})
|
||||
return contributions.map((contribution) => new Contribution(contribution, new User(user)))
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user