Commit Graph

235 Commits

Author SHA1 Message Date
Robert Speicher c8b802471b Enable the RSpec/HookArgument cop and auto-correct offenses 2017-08-10 19:29:42 -04:00
Robert Speicher 72a7b30c9f Change all `:empty_project` to `:project` 2017-08-02 17:47:31 -04:00
Robert Speicher 9513bd18c4 Ensure all project factories use `:repository` trait or `:empty_project` 2017-08-01 14:51:52 -04: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
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
Jarka Kadlecova 7bee7b848a Support both internal and external issue trackers 2017-07-24 08:13:43 +02:00
Sean McGivern 8170384d80 Revert "Merge branch 'revert-2c879643' into 'master'"
This reverts merge request !12633
2017-07-14 11:38:06 +00:00
Paul Charlton cb3b4a15e6 Support multiple Redis instances based on queue type 2017-07-11 03:35:47 +00:00
Stan Hu e81358b3b7 Merge branch 'fix-typo-in-sha-attribute-spec' into 'master'
Fix typo in SHA attribute spec

See merge request !12717
2017-07-07 19:09:05 +00:00
Stan Hu 33039ffdb5 Fix another typo in SHA attribute spec 2017-07-07 11:06:31 -07:00
Sean McGivern 7c35ecf7e4 Merge branch 'active-record-each-batch' into 'master'
Added EachBatch for iterating tables in batches

See merge request !12707
2017-07-07 17:14:42 +00:00
Sean McGivern 1271349d74 Fix typo in SHA attribute spec 2017-07-07 17:34:08 +01:00
Yorick Peterse ff78af152c
Added EachBatch for iterating tables in batches
This module provides a class method called `each_batch` that can be used
to iterate tables in batches in a more efficient way compared to Rails'
`in_batches` method. This commit also includes a RuboCop cop to
blacklist the use of `in_batches` in favour of this new method.
2017-07-07 16:39:36 +02:00
Sean McGivern 38fd773bd3 Fix ShaAttribute concern when there is no table
When this is added to a new model, it would fail before the migrations were run
- including when trying to run migrations in production mode!
2017-07-07 12:42:38 +01:00
Yorick Peterse c63e322158
Add many foreign keys to the projects table
This removes the need for relying on Rails' "dependent" option for data
removal, which is _incredibly_ slow (even when using :delete_all) when
deleting large amounts of data. This also ensures data consistency is
enforced on DB level and not on application level (something Rails is
really bad at).

This commit also includes various migrations to add foreign keys to
tables that eventually point to "projects" to ensure no rows get
orphaned upon removing a project.
2017-07-06 12:01:36 +02:00
Douwe Maan 2c78c7f4cd Revert "Merge branch 'revert-12499' into 'master'"
This reverts merge request !12557
2017-07-04 17:08:41 +00:00
Douglas Barbosa Alexandre ea9dd29a76 Reset @full_path to nil when cache expires 2017-07-03 12:38:01 -03:00
Douglas Barbosa Alexandre 2446252cfd Expires full_path cache after project is renamed 2017-06-29 19:11:48 -03:00
Robert Speicher 066a6c8ba8 Merge branch '34078-allow-to-enable-feature-flags-with-more-granularity' into 'master'
Allow the feature flags to be enabled/disabled with more granularity

Closes #34078

See merge request !12357
2017-06-29 16:36:22 +00:00
Sean McGivern 31c21d50fc Merge branch 'sha-attributes-for-postgresql-and-mysql' into 'master'
Added code for defining SHA attributes

See merge request !12555
2017-06-29 15:20:47 +00:00
Adam Niedzielski a3d7983b18 Revert "Merge branch 'dm-drop-default-scope-on-sortable-finders' into 'master'"
This reverts commit b07c00032b, reversing
changes made to 2b97d76d0b.
2017-06-29 16:14:12 +02:00
Yorick Peterse af1f6844c9
Added code for defining SHA attributes
These attributes are stored in binary in the database, but exposed as
strings. This allows one to query/create data using plain SHA1 hashes as
Strings, while storing them more efficiently as binary.
2017-06-29 15:37:37 +02:00
Kamil Trzciński 36e17d0fa8 Merge branch 'feature/sm/34314-add-hasvariable-concern' into 'master'
Implement `HasVariable` concern

Closes #34314

See merge request !12448
2017-06-29 08:14:08 +00:00
Douwe Maan 4d6ee98d86 Drop default ORDER scope when calling a find method on a Sortable model 2017-06-28 14:23:36 -05:00
Shinya Maeda de893b19c3 Improve small things 2017-06-28 15:25:36 +09:00
Shinya Maeda 41aebaa103 Decuplin 2017-06-28 15:20:50 +09:00
Rémy Coutable 5fa9d6a17d Rename FLippable to FeatureGate and make `flipper_group` and `user` mutually exclusive
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-27 18:59:51 +02:00
Kamil Trzciński 4503240abd Merge branch 'fix/gb/fix-skipped-pipeline-with-allowed-to-fail-jobs' into 'master'
Fix pipeline status when allowed to fail jobs present

Closes #29059

See merge request !11166
2017-06-26 09:48:48 +00:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Grzegorz Bizon 51ce9a6caa Fix specs for a concern that implements CI/CD statuses 2017-06-20 15:32:29 +02:00
Felipe Artur 0520ee4498 Improve method names and add more specs 2017-06-16 12:03:15 -03:00
Felipe Artur 2e3f0b08fb Remove old specs and add new ones 2017-06-16 12:02:20 -03:00
Robert Speicher a6ec5121f0 Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
Oswaldo Ferreira 34ba80392d Use :request_store hooks on specs 2017-06-09 18:18:36 -03:00
Luke "Jared" Bennett 07c984d81c
Port fix-realtime-edited-text-for-issues 9-2-stable fix to master. 2017-05-31 11:35:05 +01:00
Douwe Maan 26bcef97d6 Merge branch 'rework-authorizations-performance' into 'master'
Rework project authorizations and nested groups for better performance

See merge request !10885
2017-05-29 15:49:56 +00:00
Douwe Maan 0bf339f0ed Address review 2017-05-24 10:10:10 -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
Dmitriy Zaporozhets 11ff9fc6a9 Merge branch '28359-skip-process-commit-worker-unless-issues-referenced' into 'master'
Use regex to skip unnecessary reference processing in ProcessCommitWorker

Closes #28359

See merge request !10867
2017-05-08 12:54:23 +00:00
Sean McGivern 56fb7823f9 Merge branch '17361-redirect-renamed-paths' into 'master'
Resolve "Redirect to new project link after a rename"

Closes #17361 and #30317

See merge request !11136
2017-05-06 05:45:56 +00:00
Michael Kozono 7d02bcd2e0 Redirect from redirect routes to canonical routes 2017-05-05 12:11:57 -07:00
James Edwards-Jones 020295fffc Use regex to skip unnecessary reference processing in ProcessCommitWorker 2017-05-04 20:03:46 +01:00
Valery Sizov 387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Bob Van Landuyt 3dd2476eb3 Refresh the markdown cache if it was `nil`
If the cached html_field for a markdown_field is `nil` while the
mfarkdown_field is not, it needs to be refreshed.
2017-05-02 15:24:41 +02:00
Robert Speicher 2952a44779 Merge branch 'enable-spec-file-name-cop' into 'master'
Enable RSpec/FilePath cop

Closes #31316

See merge request !10911
2017-04-28 18:02:17 +00:00
Sean McGivern 5069682d8e Enable RSpec/FilePath cop
- Ignore JS fixtures
- Ignore qa directory
- Rewrite concern specs to put concern name first
2017-04-26 12:50:32 +01:00
Nick Thomas 0e24b1280e Fix a failing spec 2017-04-25 17:13:44 +01:00
Stan Hu a0edaa9210 Cache Routable#full_path in RequestStore to reduce duplicate route loads
We see in #27387 that a call to `polymorphic_path` will cause duplicate
SELECT route calls for each merge request in a milestone. This happens
because calling `project.namespace.becomes(Namespace)` will instantiate
a new instance of a Namespace for each merge request, which causes a N+1
query on the routes table. This change caches the state of the route by
the specific class and ID, which dramatically eliminates duplicate work.
2017-04-24 06:43:24 -07:00
Nick Thomas d2b883b750 Start versioning cached markdown fields 2017-04-21 17:24:33 +01:00
Nick Thomas e9819de10a Remove the ClearDatabaseCacheWorker 2017-04-21 11:52:28 +01:00