diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-01 12:10:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-01 12:10:58 +0300 |
commit | 0356944a052f481f63a4d6f18510e7f42516cc44 (patch) | |
tree | 74620c1ca92198cf9d6ed2bc8e22182d0460c8b2 /lib | |
parent | dbc554cda7f86f22d34fd1e3a4ec4ab677d55879 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/experimentation.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/object_hierarchy.rb | 24 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/learn_gitlab_menu.rb | 3 |
3 files changed, 18 insertions, 17 deletions
diff --git a/lib/gitlab/experimentation.rb b/lib/gitlab/experimentation.rb index d3503e19d5d..c74bd8e75ef 100644 --- a/lib/gitlab/experimentation.rb +++ b/lib/gitlab/experimentation.rb @@ -44,14 +44,6 @@ module Gitlab show_trial_status_in_sidebar: { tracking_category: 'Growth::Conversion::Experiment::ShowTrialStatusInSidebar', rollout_strategy: :group - }, - learn_gitlab_a: { - tracking_category: 'Growth::Conversion::Experiment::LearnGitLabA', - rollout_strategy: :user - }, - learn_gitlab_b: { - tracking_category: 'Growth::Activation::Experiment::LearnGitLabB', - rollout_strategy: :user } }.freeze diff --git a/lib/gitlab/object_hierarchy.rb b/lib/gitlab/object_hierarchy.rb index 2e54e8bfc1a..693f1470d9d 100644 --- a/lib/gitlab/object_hierarchy.rb +++ b/lib/gitlab/object_hierarchy.rb @@ -65,8 +65,15 @@ module Gitlab # Note: By default the order is breadth-first # rubocop: disable CodeReuse/ActiveRecord def base_and_ancestors(upto: nil, hierarchy_order: nil) - recursive_query = base_and_ancestors_cte(upto, hierarchy_order).apply_to(unscoped_model.all) - recursive_query = recursive_query.order(depth: hierarchy_order) if hierarchy_order + cte = base_and_ancestors_cte(upto, hierarchy_order) + + recursive_query = if hierarchy_order + # othewise depth won't be available for outer query + cte.apply_to(unscoped_model.all.select(objects_table[Arel.star])).order(depth: hierarchy_order) + else + cte.apply_to(unscoped_model.all) + end + read_only(recursive_query) end # rubocop: enable CodeReuse/ActiveRecord @@ -78,7 +85,10 @@ module Gitlab # and incremented as we go down the descendant tree # rubocop: disable CodeReuse/ActiveRecord def base_and_descendants(with_depth: false) - read_only(base_and_descendants_cte(with_depth: with_depth).apply_to(unscoped_model.all)) + outer_select_relation = unscoped_model.all + outer_select_relation = outer_select_relation.select(objects_table[Arel.star]) if with_depth # Otherwise Active Record will not select `depth` as it's not a table column + + read_only(base_and_descendants_cte(with_depth: with_depth).apply_to(outer_select_relation)) end # rubocop: enable CodeReuse/ActiveRecord @@ -145,7 +155,7 @@ module Gitlab cte = SQL::RecursiveCTE.new(:base_and_ancestors) base_query = ancestors_base.except(:order) - base_query = base_query.select("1 as #{DEPTH_COLUMN}", "ARRAY[#{objects_table.name}.id] AS tree_path", "false AS tree_cycle", objects_table[Arel.star]) if hierarchy_order + base_query = base_query.select("1 as #{DEPTH_COLUMN}", "ARRAY[#{objects_table.name}.id] AS tree_path", "false AS tree_cycle", base_query.default_select_columns) if hierarchy_order cte << base_query @@ -162,7 +172,7 @@ module Gitlab cte.table[DEPTH_COLUMN] + 1, "tree_path || #{quoted_objects_table_name}.id", "#{quoted_objects_table_name}.id = ANY(tree_path)", - objects_table[Arel.star] + parent_query.default_select_columns ).where(cte.table[:tree_cycle].eq(false)) end @@ -178,7 +188,7 @@ module Gitlab cte = SQL::RecursiveCTE.new(:base_and_descendants) base_query = descendants_base.except(:order) - base_query = base_query.select("1 AS #{DEPTH_COLUMN}", "ARRAY[#{objects_table.name}.id] AS tree_path", "false AS tree_cycle", objects_table[Arel.star]) if with_depth + base_query = base_query.select("1 AS #{DEPTH_COLUMN}", "ARRAY[#{objects_table.name}.id] AS tree_path", "false AS tree_cycle", base_query.default_select_columns) if with_depth cte << base_query @@ -195,7 +205,7 @@ module Gitlab cte.table[DEPTH_COLUMN] + 1, "tree_path || #{quoted_objects_table_name}.id", "#{quoted_objects_table_name}.id = ANY(tree_path)", - objects_table[Arel.star] + descendants_query.default_select_columns ).where(cte.table[:tree_cycle].eq(false)) end diff --git a/lib/sidebars/projects/menus/learn_gitlab_menu.rb b/lib/sidebars/projects/menus/learn_gitlab_menu.rb index f29f4a6eed6..9de141e465f 100644 --- a/lib/sidebars/projects/menus/learn_gitlab_menu.rb +++ b/lib/sidebars/projects/menus/learn_gitlab_menu.rb @@ -40,8 +40,7 @@ module Sidebars { class: 'home', data: { - track_label: 'learn_gitlab', - track_property: context.learn_gitlab_experiment_tracking_category + track_label: 'learn_gitlab' } } end |