Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 13:00:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 13:00:54 +0300
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /app/models/group_group_link.rb
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'app/models/group_group_link.rb')
-rw-r--r--app/models/group_group_link.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/group_group_link.rb b/app/models/group_group_link.rb
index c4c3fc390e1..b0020f097b5 100644
--- a/app/models/group_group_link.rb
+++ b/app/models/group_group_link.rb
@@ -16,6 +16,19 @@ class GroupGroupLink < ApplicationRecord
scope :non_guests, -> { where('group_access > ?', Gitlab::Access::GUEST) }
scope :preload_shared_with_groups, -> { preload(:shared_with_group) }
+ scope :distinct_on_shared_with_group_id_with_group_access, -> do
+ distinct_group_links = select('DISTINCT ON (shared_with_group_id) *')
+ .order('shared_with_group_id, group_access DESC, expires_at DESC, created_at ASC')
+
+ unscoped.from(distinct_group_links, :group_group_links)
+ end
+
+ alias_method :shared_from, :shared_group
+
+ def self.search(query)
+ joins(:shared_with_group).merge(Group.search(query))
+ end
+
def self.access_options
Gitlab::Access.options_with_owner
end