mirror of
https://github.com/IT4Change/gradido.git
synced 2026-03-01 12:44:43 +00:00
shorten code, position after variable decleration
This commit is contained in:
parent
31a6b28c85
commit
3521246cf1
@ -375,17 +375,9 @@ export class ContributionResolver {
|
|||||||
const result = new ContributionListResult(count, dbContributions)
|
const result = new ContributionListResult(count, dbContributions)
|
||||||
|
|
||||||
const uniqueUserIds = new Set<number>()
|
const uniqueUserIds = new Set<number>()
|
||||||
const addIfExist = (userId?: number | null) => {
|
const addIfExist = (userId?: number | null) =>
|
||||||
if (userId) {
|
userId ? uniqueUserIds.add(userId) : null
|
||||||
uniqueUserIds.add(userId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const getNameById = (userId?: number | null) => {
|
|
||||||
if (userId) {
|
|
||||||
return users.get(userId)
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
for (const contribution of result.contributionList) {
|
for (const contribution of result.contributionList) {
|
||||||
addIfExist(contribution.confirmedBy)
|
addIfExist(contribution.confirmedBy)
|
||||||
addIfExist(contribution.updatedBy)
|
addIfExist(contribution.updatedBy)
|
||||||
@ -394,6 +386,9 @@ export class ContributionResolver {
|
|||||||
addIfExist(contribution.deniedBy)
|
addIfExist(contribution.deniedBy)
|
||||||
}
|
}
|
||||||
const users = await findUserNamesByIds(Array.from(uniqueUserIds))
|
const users = await findUserNamesByIds(Array.from(uniqueUserIds))
|
||||||
|
const getNameById = (userId?: number | null) =>
|
||||||
|
userId ? users.get(userId) ?? null : null
|
||||||
|
|
||||||
for (const contribution of result.contributionList) {
|
for (const contribution of result.contributionList) {
|
||||||
contribution.confirmedByUserName = getNameById(contribution.confirmedBy)
|
contribution.confirmedByUserName = getNameById(contribution.confirmedBy)
|
||||||
contribution.updatedByUserName = getNameById(contribution.updatedBy)
|
contribution.updatedByUserName = getNameById(contribution.updatedBy)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user