Skip to content

Conversation

@jmgasper
Copy link
Contributor

No description provided.

@jmgasper jmgasper requested a review from kkartunov October 30, 2025 19:54
* @param {Array} resources resources of current user for specified challenge id
*/
async function checkAccess (currentUserResources) {
const copilotRoleIds = await getCopilotResourceRoleIds()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
Consider caching the result of getCopilotResourceRoleIds() if it is expected to be called frequently. This could improve performance by reducing database queries.

*/
async function checkAccess (currentUserResources) {
const copilotRoleIds = await getCopilotResourceRoleIds()
const hasCopilotRole = _.some(currentUserResources, r => copilotRoleIds.includes(r.roleId))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 performance]
The use of _.some with includes is correct, but ensure that currentUserResources and copilotRoleIds are not excessively large, as this could impact performance. If they are, consider optimizing the data structure or approach.

})

it('copilot can manage resources without full access flags', async () => {
const originalRole = await helper.getById('ResourceRole', copilotRoleId)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The test case modifies the ResourceRole to have no full access flags and then attempts to create a resource with a user that might not have the necessary permissions. Ensure that the test setup accurately reflects the intended permissions and that the test case is valid under the new role configuration.

await assertResource(createdResource.id, createdResource)
} finally {
if (createdResource && createdResource.id) {
await prisma.resource.deleteMany({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 maintainability]
Consider using delete instead of deleteMany if you are certain that only one resource will be deleted. This can prevent accidental deletion of multiple resources if the query conditions are not as expected.

@jmgasper jmgasper merged commit ea06535 into develop Nov 1, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants