shorten code, position after variable decleration

This commit is contained in:
einhornimmond 2025-12-17 14:03:02 +01:00
parent 31a6b28c85
commit 3521246cf1

View File

@ -375,17 +375,9 @@ export class ContributionResolver {
const result = new ContributionListResult(count, dbContributions)
const uniqueUserIds = new Set<number>()
const addIfExist = (userId?: number | null) => {
if (userId) {
uniqueUserIds.add(userId)
}
}
const getNameById = (userId?: number | null) => {
if (userId) {
return users.get(userId)
}
return null
}
const addIfExist = (userId?: number | null) =>
userId ? uniqueUserIds.add(userId) : null
for (const contribution of result.contributionList) {
addIfExist(contribution.confirmedBy)
addIfExist(contribution.updatedBy)
@ -394,6 +386,9 @@ export class ContributionResolver {
addIfExist(contribution.deniedBy)
}
const users = await findUserNamesByIds(Array.from(uniqueUserIds))
const getNameById = (userId?: number | null) =>
userId ? users.get(userId) ?? null : null
for (const contribution of result.contributionList) {
contribution.confirmedByUserName = getNameById(contribution.confirmedBy)
contribution.updatedByUserName = getNameById(contribution.updatedBy)