Skip to content
代码片段 群组 项目
未验证 提交 0fbd6fc5 编辑于 作者: Adam Hegyi's avatar Adam Hegyi 提交者: GitLab
浏览文件

Merge branch '442797-optimize-todos-query' into 'master'

Optimize todos query when filtering by group

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/153226



Merged-by: default avatarAdam Hegyi <ahegyi@gitlab.com>
Approved-by: default avatarIvane Gkomarteli <igkomarteli@gitlab.com>
Approved-by: default avatarAdam Hegyi <ahegyi@gitlab.com>
Reviewed-by: default avatarMohamed Hamda <mhamda@gitlab.com>
Co-authored-by: default avatarHeinrich Lee Yu <heinrich@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -107,13 +107,18 @@ class << self
#
# Returns an `ActiveRecord::Relation`.
def for_group_ids_and_descendants(group_ids)
groups = Group.where(id: group_ids).self_and_descendants
from_union(
[
for_project(Project.for_group(groups)),
for_group(groups)
])
groups_and_descendants_cte = Gitlab::SQL::CTE.new(
:groups_and_descendants_ids,
Group.where(id: group_ids).self_and_descendant_ids
)
groups_and_descendants = Namespace.from(groups_and_descendants_cte.table)
with(groups_and_descendants_cte.to_arel)
.from_union([
for_project(Project.for_group(groups_and_descendants)),
for_group(groups_and_descendants)
], remove_duplicates: false)
end
# Returns `true` if the current user has any todos for the given target with the optional given state.
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册