Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
d3f5e78b
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,发现更多精彩内容 >>
提交
d3f5e78b
编写于
7月 24, 2017
作者:
R
Rémy Coutable
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '28202_decrease_abc_threshold_step2' into 'master'
Decrease ABC threshold to 56.96 See merge request !11227
上级
56977be3
fab1b0f1
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
177 addition
and
13 deletion
+177
-13
.rubocop.yml
.rubocop.yml
+1
-1
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+3
-12
app/finders/admin/projects_finder.rb
app/finders/admin/projects_finder.rb
+33
-0
changelogs/unreleased/28202_decrease_abc_threshold_step2.yml
changelogs/unreleased/28202_decrease_abc_threshold_step2.yml
+4
-0
spec/finders/admin/projects_finder_spec.rb
spec/finders/admin/projects_finder_spec.rb
+136
-0
未找到文件。
.rubocop.yml
浏览文件 @
d3f5e78b
...
@@ -563,7 +563,7 @@ Style/Proc:
...
@@ -563,7 +563,7 @@ Style/Proc:
# branches, and conditions.
# branches, and conditions.
Metrics/AbcSize
:
Metrics/AbcSize
:
Enabled
:
true
Enabled
:
true
Max
:
5
7.08
Max
:
5
6.96
# This cop checks if the length of a block exceeds some maximum value.
# This cop checks if the length of a block exceeds some maximum value.
Metrics/BlockLength
:
Metrics/BlockLength
:
...
...
app/controllers/admin/projects_controller.rb
浏览文件 @
d3f5e78b
...
@@ -3,18 +3,9 @@ class Admin::ProjectsController < Admin::ApplicationController
...
@@ -3,18 +3,9 @@ class Admin::ProjectsController < Admin::ApplicationController
before_action
:group
,
only:
[
:show
,
:transfer
]
before_action
:group
,
only:
[
:show
,
:transfer
]
def
index
def
index
params
[
:sort
]
||=
'latest_activity_desc'
finder
=
Admin
::
ProjectsFinder
.
new
(
params:
params
,
current_user:
current_user
)
@projects
=
Project
.
with_statistics
@projects
=
finder
.
execute
@projects
=
@projects
.
in_namespace
(
params
[
:namespace_id
])
if
params
[
:namespace_id
].
present?
@sort
=
finder
.
sort
@projects
=
@projects
.
where
(
visibility_level:
params
[
:visibility_level
])
if
params
[
:visibility_level
].
present?
@projects
=
@projects
.
with_push
if
params
[
:with_push
].
present?
@projects
=
@projects
.
abandoned
if
params
[
:abandoned
].
present?
@projects
=
@projects
.
where
(
last_repository_check_failed:
true
)
if
params
[
:last_repository_check_failed
].
present?
@projects
=
@projects
.
non_archived
unless
params
[
:archived
].
present?
@projects
=
@projects
.
personal
(
current_user
)
if
params
[
:personal
].
present?
@projects
=
@projects
.
search
(
params
[
:name
])
if
params
[
:name
].
present?
@projects
=
@projects
.
sort
(
@sort
=
params
[
:sort
])
@projects
=
@projects
.
includes
(
:namespace
).
order
(
"namespaces.path, projects.name ASC"
).
page
(
params
[
:page
])
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
...
...
app/finders/admin/projects_finder.rb
0 → 100644
浏览文件 @
d3f5e78b
class
Admin::ProjectsFinder
attr_reader
:sort
,
:namespace_id
,
:visibility_level
,
:with_push
,
:abandoned
,
:last_repository_check_failed
,
:archived
,
:personal
,
:name
,
:page
,
:current_user
def
initialize
(
params
:,
current_user
:)
@current_user
=
current_user
@sort
=
params
.
fetch
(
:sort
)
{
'latest_activity_desc'
}
@namespace_id
=
params
[
:namespace_id
]
@visibility_level
=
params
[
:visibility_level
]
@with_push
=
params
[
:with_push
]
@abandoned
=
params
[
:abandoned
]
@last_repository_check_failed
=
params
[
:last_repository_check_failed
]
@archived
=
params
[
:archived
]
@personal
=
params
[
:personal
]
@name
=
params
[
:name
]
@page
=
params
[
:page
]
end
def
execute
items
=
Project
.
with_statistics
items
=
items
.
in_namespace
(
namespace_id
)
if
namespace_id
.
present?
items
=
items
.
where
(
visibility_level:
visibility_level
)
if
visibility_level
.
present?
items
=
items
.
with_push
if
with_push
.
present?
items
=
items
.
abandoned
if
abandoned
.
present?
items
=
items
.
where
(
last_repository_check_failed:
true
)
if
last_repository_check_failed
.
present?
items
=
items
.
non_archived
unless
archived
.
present?
items
=
items
.
personal
(
current_user
)
if
personal
.
present?
items
=
items
.
search
(
name
)
if
name
.
present?
items
=
items
.
sort
(
sort
)
items
.
includes
(
:namespace
).
order
(
"namespaces.path, projects.name ASC"
).
page
(
page
)
end
end
changelogs/unreleased/28202_decrease_abc_threshold_step2.yml
0 → 100644
浏览文件 @
d3f5e78b
---
title
:
Decrease ABC threshold to
56.96
merge_request
:
11227
author
:
Maxim Rydkin
spec/finders/admin/projects_finder_spec.rb
0 → 100644
浏览文件 @
d3f5e78b
require
'spec_helper'
describe
Admin
::
ProjectsFinder
do
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
:public
)
}
let!
(
:private_project
)
do
create
(
:empty_project
,
:private
,
name:
'A'
,
path:
'A'
)
end
let!
(
:internal_project
)
do
create
(
:empty_project
,
:internal
,
group:
group
,
name:
'B'
,
path:
'B'
)
end
let!
(
:public_project
)
do
create
(
:empty_project
,
:public
,
group:
group
,
name:
'C'
,
path:
'C'
)
end
let!
(
:shared_project
)
do
create
(
:empty_project
,
:private
,
name:
'D'
,
path:
'D'
)
end
let
(
:params
)
{
{}
}
let
(
:current_user
)
{
user
}
let
(
:project_ids_relation
)
{
nil
}
let
(
:finder
)
{
described_class
.
new
(
params:
params
,
current_user:
current_user
)
}
subject
{
finder
.
execute
.
to_a
}
context
'without a user'
do
let
(
:current_user
)
{
nil
}
it
{
is_expected
.
to
eq
([
shared_project
,
public_project
,
internal_project
,
private_project
])
}
end
context
'with a user'
do
it
{
is_expected
.
to
eq
([
shared_project
,
public_project
,
internal_project
,
private_project
])
}
end
context
'filter by namespace_id'
do
let
(
:namespace
)
{
create
(
:namespace
)
}
let!
(
:project_in_namespace
)
{
create
(
:empty_project
,
namespace:
namespace
)
}
let
(
:params
)
{
{
namespace_id:
namespace
.
id
}
}
it
{
is_expected
.
to
eq
([
project_in_namespace
])
}
end
context
'filter by visibility_level'
do
before
do
private_project
.
add_master
(
user
)
end
context
'private'
do
let
(
:params
)
{
{
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
}
}
it
{
is_expected
.
to
eq
([
shared_project
,
private_project
])
}
end
context
'internal'
do
let
(
:params
)
{
{
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
}
}
it
{
is_expected
.
to
eq
([
internal_project
])
}
end
context
'public'
do
let
(
:params
)
{
{
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
}
}
it
{
is_expected
.
to
eq
([
public_project
])
}
end
end
context
'filter by push'
do
let
(
:pushed_event
)
{
create
(
:event
,
:pushed
)
}
let!
(
:project_with_push
)
{
pushed_event
.
project
}
let
(
:params
)
{
{
with_push:
true
}
}
it
{
is_expected
.
to
eq
([
project_with_push
])
}
end
context
'filter by abandoned'
do
before
do
private_project
.
update
(
last_activity_at:
Time
.
zone
.
now
-
6
.
months
-
1
.
minute
)
end
let
(
:params
)
{
{
abandoned:
true
}
}
it
{
is_expected
.
to
eq
([
private_project
])
}
end
context
'filter by last_repository_check_failed'
do
before
do
private_project
.
update
(
last_repository_check_failed:
true
)
end
let
(
:params
)
{
{
last_repository_check_failed:
true
}
}
it
{
is_expected
.
to
eq
([
private_project
])
}
end
context
'filter by archived'
do
let!
(
:archived_project
)
{
create
(
:empty_project
,
:public
,
:archived
,
name:
'E'
,
path:
'E'
)
}
context
'archived=false'
do
let
(
:params
)
{
{
archived:
false
}
}
it
{
is_expected
.
to
match_array
([
shared_project
,
public_project
,
internal_project
,
private_project
])
}
end
context
'archived=true'
do
let
(
:params
)
{
{
archived:
true
}
}
it
{
is_expected
.
to
match_array
([
archived_project
,
shared_project
,
public_project
,
internal_project
,
private_project
])
}
end
end
context
'filter by personal'
do
let!
(
:personal_project
)
{
create
(
:empty_project
,
namespace:
user
.
namespace
)
}
let
(
:params
)
{
{
personal:
true
}
}
it
{
is_expected
.
to
eq
([
personal_project
])
}
end
context
'filter by name'
do
let
(
:params
)
{
{
name:
'C'
}
}
it
{
is_expected
.
to
eq
([
shared_project
,
public_project
,
private_project
])
}
end
context
'sorting'
do
let
(
:params
)
{
{
sort:
'name_asc'
}
}
it
{
is_expected
.
to
eq
([
private_project
,
internal_project
,
public_project
,
shared_project
])
}
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录