Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
06d4f07a
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
06d4f07a
编写于
12月 26, 2017
作者:
F
Felipe Artur
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve filtering issues by label performance
上级
a5a0f3f7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
122 addition
and
13 deletion
+122
-13
app/controllers/concerns/issues_action.rb
app/controllers/concerns/issues_action.rb
+0
-2
app/controllers/concerns/merge_requests_action.rb
app/controllers/concerns/merge_requests_action.rb
+0
-1
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+5
-10
changelogs/unreleased/issue_40500.yml
changelogs/unreleased/issue_40500.yml
+5
-0
db/fixtures/development/22_labeled_issues_seed.rb
db/fixtures/development/22_labeled_issues_seed.rb
+112
-0
未找到文件。
app/controllers/concerns/issues_action.rb
浏览文件 @
06d4f07a
...
...
@@ -5,8 +5,6 @@ module IssuesAction
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def
issues
@finder_type
=
IssuesFinder
@label
=
finder
.
labels
.
first
@issues
=
issuables_collection
.
non_archived
.
page
(
params
[
:page
])
...
...
app/controllers/concerns/merge_requests_action.rb
浏览文件 @
06d4f07a
...
...
@@ -5,7 +5,6 @@ module MergeRequestsAction
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def
merge_requests
@finder_type
=
MergeRequestsFinder
@label
=
finder
.
labels
.
first
@merge_requests
=
issuables_collection
.
page
(
params
[
:page
])
...
...
app/finders/issuable_finder.rb
浏览文件 @
06d4f07a
...
...
@@ -374,19 +374,14 @@ class IssuableFinder
end
def
by_label
(
items
)
if
labels?
return
items
unless
labels?
items
=
if
filter_by_no_label?
items
=
items
.
without_label
items
.
without_label
else
items
=
items
.
with_label
(
label_names
,
params
[
:sort
])
items_projects
=
projects
(
items
)
if
items_projects
label_ids
=
LabelsFinder
.
new
(
current_user
,
project_ids:
items_projects
).
execute
(
skip_authorization:
true
).
select
(
:id
)
items
=
items
.
where
(
labels:
{
id:
label_ids
})
end
items
.
with_label
(
label_names
,
params
[
:sort
])
end
end
items
end
...
...
changelogs/unreleased/issue_40500.yml
0 → 100644
浏览文件 @
06d4f07a
---
title
:
Fix timeout when filtering issues by label
merge_request
:
author
:
type
:
performance
db/fixtures/development/22_labeled_issues_seed.rb
0 → 100644
浏览文件 @
06d4f07a
# Creates a project with labeled issues for a user.
# Run this single seed file using: rake db:seed_fu FILTER=labeled USER_ID=74.
# If an USER_ID is not provided it will use the last created user.
require
'./spec/support/sidekiq'
class
Gitlab::Seeder::LabeledIssues
include
::
Gitlab
::
Utils
def
initialize
(
user
)
@user
=
user
end
def
seed!
Sidekiq
::
Testing
.
inline!
do
group
=
create_group
puts
'.'
create_projects
(
group
)
puts
'.'
create_labels
(
group
)
puts
'.'
create_issues
(
group
)
puts
'.'
end
print
'.'
end
private
def
create_group
group_name
=
"group_of_
#{
@user
.
name
}#{
SecureRandom
.
hex
(
4
)
}
"
group
=
Group
.
new
(
name:
group_name
,
path:
group_name
,
description:
FFaker
::
Lorem
.
sentence
)
group
.
save
group
.
add_owner
(
@user
)
group
end
def
create_projects
(
group
)
5
.
times
do
project_name
=
"project_
#{
SecureRandom
.
hex
(
6
)
}
"
params
=
{
namespace_id:
group
.
id
,
name:
project_name
,
description:
FFaker
::
Lorem
.
sentence
,
visibility_level:
Gitlab
::
VisibilityLevel
.
values
.
sample
}
Projects
::
CreateService
.
new
(
@user
,
params
).
execute
end
end
def
create_labels
(
group
)
group
.
projects
.
each
do
|
project
|
5
.
times
do
label_title
=
FFaker
::
Vehicle
.
model
Labels
::
CreateService
.
new
(
title:
label_title
).
execute
(
project:
project
)
end
end
10
.
times
do
label_title
=
FFaker
::
Product
.
brand
Labels
::
CreateService
.
new
(
title:
label_title
).
execute
(
group:
group
)
end
end
def
create_issues
(
group
)
# Get only group labels
group_labels
=
LabelsFinder
.
new
(
@user
,
group_id:
group
.
id
).
execute
.
where
.
not
(
group_id:
nil
)
group
.
projects
.
each
do
|
project
|
label_ids
=
project
.
labels
.
pluck
(
:id
).
sample
(
5
)
label_ids
.
push
(
*
group
.
labels
.
sample
(
4
))
50
.
times
do
issue_params
=
{
title:
FFaker
::
Lorem
.
sentence
(
6
),
description:
FFaker
::
Lorem
.
sentence
,
state:
'opened'
,
label_ids:
label_ids
}
Issues
::
CreateService
.
new
(
project
,
@user
,
issue_params
).
execute
if
project
.
project_feature
.
present?
end
end
end
end
Gitlab
::
Seeder
.
quiet
do
user_id
=
ENV
[
'USER_ID'
]
user
=
if
user_id
.
present?
User
.
find
(
user_id
)
else
User
.
last
end
Gitlab
::
Seeder
::
LabeledIssues
.
new
(
user
).
seed!
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录