diff options
-rw-r--r-- | app/finders/group_projects_finder.rb | 26 | ||||
-rw-r--r-- | changelogs/unreleased/groups-controller-show-performance.yml | 5 | ||||
-rw-r--r-- | db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb | 27 | ||||
-rw-r--r-- | db/schema.rb | 3 | ||||
-rw-r--r-- | lib/banzai/reference_parser/issue_parser.rb | 3 |
5 files changed, 44 insertions, 20 deletions
diff --git a/app/finders/group_projects_finder.rb b/app/finders/group_projects_finder.rb index f73cf8adb4d..b6bdb2b7b0f 100644 --- a/app/finders/group_projects_finder.rb +++ b/app/finders/group_projects_finder.rb @@ -39,25 +39,15 @@ class GroupProjectsFinder < ProjectsFinder end def collection_with_user - if group.users.include?(current_user) - if only_shared? - [shared_projects] - elsif only_owned? - [owned_projects] - else - [shared_projects, owned_projects] - end + if only_shared? + [shared_projects.public_or_visible_to_user(current_user)] + elsif only_owned? + [owned_projects.public_or_visible_to_user(current_user)] else - if only_shared? - [shared_projects.public_or_visible_to_user(current_user)] - elsif only_owned? - [owned_projects.public_or_visible_to_user(current_user)] - else - [ - owned_projects.public_or_visible_to_user(current_user), - shared_projects.public_or_visible_to_user(current_user) - ] - end + [ + owned_projects.public_or_visible_to_user(current_user), + shared_projects.public_or_visible_to_user(current_user) + ] end end diff --git a/changelogs/unreleased/groups-controller-show-performance.yml b/changelogs/unreleased/groups-controller-show-performance.yml new file mode 100644 index 00000000000..bab54cc455e --- /dev/null +++ b/changelogs/unreleased/groups-controller-show-performance.yml @@ -0,0 +1,5 @@ +--- +title: Improve performance of GroupsController#show +merge_request: +author: +type: performance diff --git a/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb b/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb new file mode 100644 index 00000000000..cee576b91c8 --- /dev/null +++ b/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb @@ -0,0 +1,27 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class MergeRequestsTargetIdIidStatePartialIndex < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + INDEX_NAME = 'index_merge_requests_on_target_project_id_and_iid_opened' + + disable_ddl_transaction! + + def up + # On GitLab.com this index will take up roughly 5 MB of space. + add_concurrent_index( + :merge_requests, + [:target_project_id, :iid], + where: "state = 'opened'", + name: INDEX_NAME + ) + end + + def down + remove_concurrent_index_by_name(:merge_requests, INDEX_NAME) + end +end diff --git a/db/schema.rb b/db/schema.rb index 884e333874c..a3e33c1d9aa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180521171529) do +ActiveRecord::Schema.define(version: 20180524132016) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1232,6 +1232,7 @@ ActiveRecord::Schema.define(version: 20180521171529) do add_index "merge_requests", ["source_project_id", "source_branch"], name: "index_merge_requests_on_source_project_id_and_source_branch", using: :btree add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree add_index "merge_requests", ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true, using: :btree + add_index "merge_requests", ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid_opened", where: "((state)::text = 'opened'::text)", using: :btree add_index "merge_requests", ["target_project_id", "merge_commit_sha", "id"], name: "index_merge_requests_on_tp_id_and_merge_commit_sha_and_id", using: :btree add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree add_index "merge_requests", ["title"], name: "index_merge_requests_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb index 6bee5ea15b9..7b5915899cf 100644 --- a/lib/banzai/reference_parser/issue_parser.rb +++ b/lib/banzai/reference_parser/issue_parser.rb @@ -69,7 +69,8 @@ module Banzai { group: [:owners, :group_members] }, :invited_groups, :project_members, - :project_feature + :project_feature, + :route ] } ), |