Commit Graph

30 Commits

Author SHA1 Message Date
GitLab Bot 47a3dc6551 Add latest changes from gitlab-org/gitlab@master 2022-12-21 09:07:17 +00:00
GitLab Bot 130b909c4f Add latest changes from gitlab-org/gitlab@master 2022-12-05 06:07:17 +00:00
GitLab Bot cbb1710f90 Add latest changes from gitlab-org/gitlab@master 2022-11-11 00:09:21 +00:00
GitLab Bot 4e50b9ed31 Add latest changes from gitlab-org/gitlab@master 2022-11-10 18:11:08 +00:00
GitLab Bot e01b61d83f Add latest changes from gitlab-org/gitlab@master 2022-03-22 15:07:25 +00:00
GitLab Bot ea4de09f48 Add latest changes from gitlab-org/gitlab@master 2021-03-10 21:09:10 +00:00
GitLab Bot 6c5f3e7b4e Add latest changes from gitlab-org/gitlab@master 2021-02-09 15:09:39 +00:00
GitLab Bot 6e495b4e91 Add latest changes from gitlab-org/gitlab@master 2021-02-01 09:09:28 +00:00
GitLab Bot 4f5c8572e9 Add latest changes from gitlab-org/gitlab@master 2020-06-16 18:09:01 +00:00
Stan Hu 917efc4d68 Fix typo in causing failing to test in sorting_spec.rb 2019-08-09 12:12:34 -07:00
Stan Hu 916f255bed Merge branch 'master' into sh-break-out-invited-group-members 2019-08-09 10:22:22 -07:00
Camil Staps 59976090b5
Add /starrers view for projects 2019-08-07 20:49:13 +02:00
Martin Wortschack a9f76d8311 Fix broken specs
- Add qa- selector to sort dropdown
2019-08-06 13:54:06 +02:00
Thong Kuah 73e848850c Add frozen_string_literal to spec/features
Using the sed script from
https://gitlab.com/gitlab-org/gitlab-ce/issues/59758
2019-07-26 13:23:30 +12:00
Mark Chao a63bce1a4b Resolve "Rename the `Master` role to `Maintainer`" Backend 2018-07-11 14:36:08 +00:00
Winnie Hellmann 3db2f32759 Enable Capybara/FeatureMethods cop 2018-07-05 06:32:05 +00:00
Robert Speicher 72a7b30c9f Change all `:empty_project` to `:project` 2017-08-02 17:47:31 -04:00
Keifer Furzland 7e113b6824 Remove superfluous type defs in specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:52 +02:00
Paul Charlton cb3b4a15e6 Support multiple Redis instances based on queue type 2017-07-11 03:35:47 +00:00
Robert Speicher eef068754a Merge branch 'master' into rs-sign_in 2017-07-06 12:43:51 -04:00
Douwe Maan fe13f11041 Create and use project path helpers that only need a project, no namespace 2017-07-05 11:11:59 -05:00
Robert Speicher e939bf7be1 Change gitlab_sign_in to sign_in where possible 2017-06-29 12:18:23 -04:00
Robert Speicher 45fb1f9542 Change `login_as` uses to `gitlab_sign_in` 2017-06-19 18:59:01 -05:00
Yorick Peterse ac382b5682
Use CTEs for nested groups and authorizations
This commit introduces the usage of Common Table Expressions (CTEs) to
efficiently retrieve nested group hierarchies, without having to rely on
the "routes" table (which is an _incredibly_ inefficient way of getting
the data). This requires a patch to ActiveRecord (found in the added
initializer) to work properly as ActiveRecord doesn't support WITH
statements properly out of the box.

Unfortunately MySQL provides no efficient way of getting nested groups.
For example, the old routes setup could easily take 5-10 seconds
depending on the amount of "routes" in a database. Providing vastly
different logic for both MySQL and PostgreSQL will negatively impact the
development process. Because of this the various nested groups related
methods return empty relations when used in combination with MySQL.

For project authorizations the logic is split up into two classes:

* Gitlab::ProjectAuthorizations::WithNestedGroups
* Gitlab::ProjectAuthorizations::WithoutNestedGroups

Both classes get the fresh project authorizations (= as they should be
in the "project_authorizations" table), including nested groups if
PostgreSQL is used. The logic of these two classes is quite different
apart from their public interface. This complicates development a bit,
but unfortunately there is no way around this.

This commit also introduces Gitlab::GroupHierarchy. This class can be
used to get the ancestors and descendants of a base relation, or both by
using a UNION. This in turn is used by methods such as:

* Namespace#ancestors
* Namespace#descendants
* User#all_expanded_groups

Again this class relies on CTEs and thus only works on PostgreSQL. The
Namespace methods will return an empty relation when MySQL is used,
while User#all_expanded_groups will return only the groups a user is a
direct member of.

Performance wise the impact is quite large. For example, on GitLab.com
Namespace#descendants used to take around 580 ms to retrieve data for a
particular user. Using CTEs we are able to reduce this down to roughly 1
millisecond, returning the exact same data.

== On The Fly Refreshing

Refreshing of authorizations on the fly (= when
users.authorized_projects_populated was not set) is removed with this
commit. This simplifies the code, and ensures any queries used for
authorizations are not mutated because they are executed in a Rails
scope (e.g. Project.visible_to_user).

This commit includes a migration to schedule refreshing authorizations
for all users, ensuring all of them have their authorizations in place.
Said migration schedules users in batches of 5000, with 5 minutes
between every batch to smear the load around a bit.

== Spec Changes

This commit also introduces some changes to various specs. For example,
some specs for ProjectTeam assumed that creating a personal project
would _not_ lead to the owner having access, which is incorrect. Because
we also no longer refresh authorizations on the fly for new users some
code had to be added to the "empty_project" factory. This chunk of code
ensures that the owner's permissions are refreshed after creating the
project, something that is normally done in Projects::CreateService.
2017-05-17 16:51:08 +02:00
Toon Claes ab7c90331f Add :redis keyword to some specs clear state of trackable attributes
The specs that rely on a correct value of the trackable attributes, should
include the `:redis` keyword in the spec to ensure the state is reset between
various specs.

The trackable attributes being:

- sign_in_count      : Increased every time a sign in is made (by form, openid, oauth)
- current_sign_in_at : A timestamp updated when the user signs in
- last_sign_in_at    : Holds the timestamp of the previous sign in
- current_sign_in_ip : The remote ip updated when the user sign in
- last_sign_in_ip    : Holds the remote ip of the previous sign in

The limiting of writing trackable attributes was introduced in
gitlab-org/gitlab-ce!11053.
2017-05-09 20:58:15 +02:00
Douwe Maan ad640bc5f9 Use Namespace#full_path instead of #path where appropriate 2017-02-23 17:55:01 -06:00
Nur Rony ecea127cd1 Improve test for sort dropdown on members page 2016-12-16 20:30:27 -02:00
Douglas Barbosa Alexandre 0ef2c8dfbe Use factories to create project/group membership on specs 2016-12-16 20:28:40 -02:00
Douglas Barbosa Alexandre 3a2905f507 Sort group/project members alphabetically by default 2016-12-16 20:28:38 -02:00
Douglas Barbosa Alexandre 4b7a3d0c38 Add feature spec for sort functionality on group/project members list 2016-12-16 20:28:38 -02:00