Skip to content

Commit

Permalink
refactor(condo): INFRA-535 remove select id field where it is not nec…
Browse files Browse the repository at this point in the history
…essary
  • Loading branch information
nomerdvadcatpyat committed Oct 8, 2024
1 parent c0b018a commit a93d192
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const syncOrganization = async ({ context, user, userData, organizationInfo, dvS
})
const employee = await OrganizationEmployee.getOne(adminContext, {
organization: { id: organization.id },
}, 'id')
})
await sendToCustomer({ organization })

return { organization, employee }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('syncOrganization from SBBOL', () => {

const [connectedEmployee] = await OrganizationEmployeeApi.getAll(adminContext, {
user: { id: user.id },
}, 'id')
})
await OrganizationEmployeeApi.softDelete(adminContext, connectedEmployee.id, 'id', { ...dvSenderFields })

await syncOrganization({
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('syncOrganization from SBBOL', () => {
const existingOrganizationEmployee = await OrganizationEmployeeApi.getOne(adminContext, {
user: { id: userClient.user.id },
organization: { id: existingOrganization.id },
}, 'id')
})
organizationData.meta.inn = userClient.organization.tin
await OrganizationApi.update(adminContext, existingOrganization.id, {
importId: organizationData.importId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const AcceptOrRejectOrganizationInviteService = new GQLCustomSchema('AcceptOrRej
isRejected = isRejected || false
isAccepted = isAccepted || false

let employee = await OrganizationEmployee.getOne(context, { id, deletedAt: null }, 'id')
let employee = await OrganizationEmployee.getOne(context, { id, deletedAt: null })
if (!employee) throw new GQLError({ ...ERRORS.acceptOrRejectOrganizationInviteById.INVITE_NOT_FOUND, messageInterpolation: { id } })

// if the user accepts the invitation, then update the name, phone number and email address of the employee
Expand All @@ -77,14 +77,14 @@ const AcceptOrRejectOrganizationInviteService = new GQLCustomSchema('AcceptOrRej
name: authedItem.name ? authedItem.name : null,
phone: authedItem.phone ? authedItem.phone : null,
email: authedItem.email ? authedItem.email : null,
}, 'id')
})
} else {
employee = await OrganizationEmployee.update(context, employee.id, {
dv: 1,
sender,
isRejected,
isAccepted,
}, 'id')
})
}

return await getById('OrganizationEmployee', employee.id)
Expand All @@ -102,7 +102,7 @@ const AcceptOrRejectOrganizationInviteService = new GQLCustomSchema('AcceptOrRej
isRejected = isRejected || false
isAccepted = isAccepted || false

let employee = await OrganizationEmployee.getOne(context, { inviteCode, user_is_null: true, deletedAt: null }, 'id')
let employee = await OrganizationEmployee.getOne(context, { inviteCode, user_is_null: true, deletedAt: null })
if (!employee) throw new GQLError({ ...ERRORS.acceptOrRejectOrganizationInviteByCode.INVITE_NOT_FOUND, messageInterpolation: { inviteCode } })

// if the user accepts the invitation, then update the name, phone number and email address of the employee
Expand All @@ -118,7 +118,7 @@ const AcceptOrRejectOrganizationInviteService = new GQLCustomSchema('AcceptOrRej
isRejected,
isAccepted,
...needToUpdateUserData,
}, 'id')
})

return await getById('OrganizationEmployee', employee.id)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const InviteNewOrganizationEmployeeService = new GQLCustomSchema('InviteNewOrgan
phone,
hasAllSpecializations,
...dvSenderData,
}, 'id')
})

for (const specializationIdObj of specializations) {
await OrganizationEmployeeSpecialization.create(context, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const ReplaceOrganizationEmployeeRoleService = new GQLCustomSchema('ReplaceOrgan
role: { connect: { id: newRoleId } },
},
}))
await OrganizationEmployee.updateMany(context, payloadToUpdate, 'id')
await OrganizationEmployee.updateMany(context, payloadToUpdate)

if (withDeletionOldRole) {
await loadListByChunks({
Expand Down
1 change: 0 additions & 1 deletion apps/condo/k6/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports = {
mode: 'production',
entry: {
'registerMetersReadings.test': path.join(__dirname, 'src/registerMetersReadings.test.ts'),
'getAllOrganizationEmployees.test': path.join(__dirname, 'src/getAllOrganizationEmployees.test.ts'),
'syncTourStep.test': path.join(__dirname, 'src/syncTourStep.test.ts'),
'ticket.test': path.join(__dirname, 'src/ticket.test.ts'),
'news.test': path.join(__dirname, 'src/news.test.ts'),
Expand Down

0 comments on commit a93d192

Please sign in to comment.