# Bug OP-13974 - Project.visible scope slower than it should be

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-13974

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 13.2.0 |
| Observed in versions |  |
| Sprint | 13.2.0 |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

The visible scope is still not as optimized as it could be. For a non admin user it will:

*   Check if the user has a project membership
*   Check if the user has no project membership and the project is public
*   Check if the user has the permission via a work package membership which involves
    *   Checking if the user has a work package share with the :view\_work\_packages permission
    *   Checking if the user has a project membership granting the :view\_work\_packages permission
    *   Checking if the non member role has the :view\_work\_packages permission, the user has no membership and the project is public

This is done conveniently by joining two available scopes. But it has a lot of overhead (e.g. the check for the non member to have the :view\_work\_packages permission is redundant with checking if the project is public before).

Since both scopes work on the same data structure (e.g. `members`, `member_roles` and `roles`), it might well be possible to have them use the exact same query, without nesting, and just querying for multiple permissions at the same time (`:view_project` and `:view_work_packages`).
