Commit graph

15 commits

Author SHA1 Message Date
GitLab Bot
fdb953945d Add latest changes from gitlab-org/gitlab@master 2021-03-05 12:08:55 +00:00
GitLab Bot
6965dc27dc Add latest changes from gitlab-org/gitlab@master 2021-01-12 03:10:47 +00:00
GitLab Bot
f3b791d5d5 Add latest changes from gitlab-org/gitlab@master 2020-12-17 18:10:14 +00:00
GitLab Bot
c59765a50a Add latest changes from gitlab-org/gitlab@master 2020-06-24 18:09:03 +00:00
GitLab Bot
f569792df8 Add latest changes from gitlab-org/gitlab@master 2020-04-27 18:09:41 +00:00
GitLab Bot
7cdd70dcec Add latest changes from gitlab-org/gitlab@master 2019-11-28 15:06:57 +00:00
Thong Kuah
8c42a0eac0 Add frozen_string_literal to lib part 2
Using the sed script from
https://gitlab.com/gitlab-org/gitlab-ce/issues/59758
2019-08-23 00:15:24 +12:00
Sara Ahbabou
dc00fa90e9 Squashed commits and modified visibility level output
Added changelog and rebased
2019-04-12 05:00:50 +00:00
Bob Van Landuyt
948150f050 Avoid error when no restricted levels are defined
When no visibility levels are defined they could sometimes return
`nil` instead of an empty array. In this case we want to allow all
levels.
2018-02-02 13:17:32 +01:00
Bob Van Landuyt
0618487906 Forking a project to a namespace with lower visibility.
In this case the project will get the minimum between both
visibilities.

If that visibility is restricted, then a lower level will be picked.
2017-12-29 11:15:26 +01:00
Rémy Coutable
ddccd24c13 Remove superfluous lib: true, type: redis, service: true, models: true, services: true, no_db: true, api: true
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:53 +02:00
Toon Claes
b90f1098cf Add User#full_private_access? to check if user has Private access
In CE only the admin has access to all private groups & projects. In EE also an
auditor can have full private access.

To overcome merge conflicts, or accidental incorrect access rights, abstract
this out in `User#full_private_access?`.

`User#admin?` now only should be used for admin-only features. For private
access-related features `User#full_private_access?` should be used.

Backported from gitlab-org/gitlab-ee!2199
2017-06-23 11:15:35 +02:00
Grzegorz Bizon
0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Yorick Peterse
d29347220c
Refactor ProjectsFinder#init_collection
This changes ProjectsFinder#init_collection so it no longer relies on a
UNION. For example, to get starred projects of a user we used to run:

    SELECT projects.*
    FROM projects
    WHERE projects.pending_delete = 'f'
    AND (
        projects.id IN (
            SELECT projects.id
            FROM projects
            INNER JOIN users_star_projects
                ON users_star_projects.project_id = projects.id
            INNER JOIN project_authorizations
                ON projects.id = project_authorizations.project_id
            WHERE projects.pending_delete = 'f'
            AND project_authorizations.user_id = 1
            AND users_star_projects.user_id = 1

            UNION

            SELECT projects.id
            FROM projects
            INNER JOIN users_star_projects
                ON users_star_projects.project_id = projects.id
            WHERE projects.visibility_level IN (20, 10)
            AND users_star_projects.user_id = 1
        )
    )
    ORDER BY projects.id DESC;

With these changes the above query is turned into the following instead:

    SELECT projects.*
    FROM projects
    INNER JOIN users_star_projects
        ON users_star_projects.project_id = projects.id
    WHERE projects.pending_delete = 'f'
    AND (
        EXISTS (
            SELECT 1
            FROM project_authorizations
            WHERE project_authorizations.user_id = 1
            AND (project_id = projects.id)
        )
        OR projects.visibility_level IN (20,10)
    )
    AND users_star_projects.user_id = 1
    ORDER BY projects.id DESC;

This query in turn produces a better execution plan and takes less time,
though the difference is only a few milliseconds (this however depends
on the amount of data involved and additional conditions that may be
added).
2017-06-16 13:49:09 +02:00
Toon Claes
71306f14f6 Make level_value accept string integers
When a VisibilityLevel is an integer formatted as a string, convert it
to an integer, instead of looking it up in the hash map.

When the value is not recognized, default to PRIVATE.
2017-03-20 22:53:29 +01:00