Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
f5b792e2
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,体验更适合开发者的 AI 搜索 >>
提交
f5b792e2
编写于
11月 18, 2016
作者:
J
James Lopez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactored updater and updated specs
上级
0aa47788
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
35 addition
and
60 deletion
+35
-60
app/controllers/projects/cycle_analytics/events_controller.rb
...controllers/projects/cycle_analytics/events_controller.rb
+1
-9
lib/gitlab/cycle_analytics/author_updater.rb
lib/gitlab/cycle_analytics/author_updater.rb
+0
-9
lib/gitlab/cycle_analytics/base_event.rb
lib/gitlab/cycle_analytics/base_event.rb
+1
-1
lib/gitlab/cycle_analytics/build_updater.rb
lib/gitlab/cycle_analytics/build_updater.rb
+0
-9
lib/gitlab/cycle_analytics/staging_event.rb
lib/gitlab/cycle_analytics/staging_event.rb
+1
-1
lib/gitlab/cycle_analytics/updater.rb
lib/gitlab/cycle_analytics/updater.rb
+7
-7
spec/lib/gitlab/cycle_analytics/author_updater_spec.rb
spec/lib/gitlab/cycle_analytics/author_updater_spec.rb
+0
-12
spec/lib/gitlab/cycle_analytics/build_updater_spec.rb
spec/lib/gitlab/cycle_analytics/build_updater_spec.rb
+0
-12
spec/lib/gitlab/cycle_analytics/updater_spec.rb
spec/lib/gitlab/cycle_analytics/updater_spec.rb
+25
-0
未找到文件。
app/controllers/projects/cycle_analytics/events_controller.rb
浏览文件 @
f5b792e2
...
...
@@ -4,7 +4,7 @@ module Projects
include
CycleAnalyticsParams
before_action
:authorize_read_cycle_analytics!
before_action
:authorize_
builds
!
,
only:
[
:test
,
:staging
]
before_action
:authorize_
read_build
!
,
only:
[
:test
,
:staging
]
before_action
:authorize_read_issue!
,
only:
[
:issue
,
:production
]
before_action
:authorize_read_merge_request!
,
only:
[
:code
,
:review
]
...
...
@@ -60,14 +60,6 @@ module Projects
params
[
:events
].
slice
(
:start_date
,
:branch_name
)
end
def
authorize_builds!
return
access_denied!
unless
can?
(
current_user
,
:read_build
,
project
)
end
def
authorize_read_issue!
return
access_denied!
unless
can?
(
current_user
,
:read_issue
,
project
)
end
end
end
end
lib/gitlab/cycle_analytics/author_updater.rb
已删除
100644 → 0
浏览文件 @
0aa47788
module
Gitlab
module
CycleAnalytics
class
AuthorUpdater
<
Updater
def
self
.
update!
(
event_result
)
new
(
event_result
,
User
,
:author
).
update!
end
end
end
end
lib/gitlab/cycle_analytics/base_event.rb
浏览文件 @
f5b792e2
...
...
@@ -30,7 +30,7 @@ module Gitlab
def
update_author!
return
unless
event_result
.
any?
&&
event_result
.
first
[
'author_id'
]
AuthorUpdater
.
update!
(
event_result
)
Updater
.
update!
(
event_result
,
from:
'author_id'
,
to:
'author'
,
klass:
User
)
end
def
event_result
...
...
lib/gitlab/cycle_analytics/build_updater.rb
已删除
100644 → 0
浏览文件 @
0aa47788
module
Gitlab
module
CycleAnalytics
class
BuildUpdater
<
Updater
def
self
.
update!
(
event_result
)
new
(
event_result
,
::
Ci
::
Build
,
:build
,
'id'
).
update!
end
end
end
end
lib/gitlab/cycle_analytics/staging_event.rb
浏览文件 @
f5b792e2
...
...
@@ -12,7 +12,7 @@ module Gitlab
end
def
fetch
BuildUpdater
.
update!
(
event_result
)
Updater
.
update!
(
event_result
,
from:
'id'
,
to:
'build'
,
klass:
::
Ci
::
Build
)
super
end
...
...
lib/gitlab/cycle_analytics/updater.rb
浏览文件 @
f5b792e2
...
...
@@ -5,25 +5,25 @@ module Gitlab
new
(
*
args
).
update!
end
def
initialize
(
event_result
,
update_klass
,
update_key
,
column
=
nil
)
def
initialize
(
event_result
,
from
:,
to
:,
klass
:
)
@event_result
=
event_result
@
update_klass
=
update_
klass
@
update_key
=
update_key
.
to_s
@
column
=
column
||
"
#{
@update_key
}
_id"
@
klass
=
klass
@
from
=
from
@
to
=
to
end
def
update!
@event_result
.
each
do
|
event
|
event
[
@
update_key
]
=
items
[
event
.
delete
(
@column
).
to_i
].
first
event
[
@
to
]
=
items
[
event
.
delete
(
@from
).
to_i
].
first
end
end
def
result_ids
@event_result
.
map
{
|
event
|
event
[
@
column
]
}
@event_result
.
map
{
|
event
|
event
[
@
from
]
}
end
def
items
@items
||=
@
update_
klass
.
find
(
result_ids
).
group_by
{
|
item
|
item
[
'id'
]
}
@items
||=
@klass
.
find
(
result_ids
).
group_by
{
|
item
|
item
[
'id'
]
}
end
end
end
...
...
spec/lib/gitlab/cycle_analytics/author_updater_spec.rb
已删除
100644 → 0
浏览文件 @
0aa47788
require
'spec_helper'
describe
Gitlab
::
CycleAnalytics
::
AuthorUpdater
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:events
)
{
[{
'author_id'
=>
user
.
id
}]
}
it
'maps the correct user'
do
described_class
.
update!
(
events
)
expect
(
events
.
first
[
'author'
]).
to
eq
(
user
)
end
end
spec/lib/gitlab/cycle_analytics/build_updater_spec.rb
已删除
100644 → 0
浏览文件 @
0aa47788
require
'spec_helper'
describe
Gitlab
::
CycleAnalytics
::
BuildUpdater
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:events
)
{
[{
'id'
=>
build
.
id
}]
}
it
'maps the correct build'
do
described_class
.
update!
(
events
)
expect
(
events
.
first
[
'build'
]).
to
eq
(
build
)
end
end
spec/lib/gitlab/cycle_analytics/updater_spec.rb
0 → 100644
浏览文件 @
f5b792e2
require
'spec_helper'
describe
Gitlab
::
CycleAnalytics
::
Updater
do
describe
'updates authors'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:events
)
{
[{
'author_id'
=>
user
.
id
}]
}
it
'maps the correct user'
do
described_class
.
update!
(
events
,
from:
'author_id'
,
to:
'author'
,
klass:
User
)
expect
(
events
.
first
[
'author'
]).
to
eq
(
user
)
end
end
describe
'updates builds'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:events
)
{
[{
'id'
=>
build
.
id
}]
}
it
'maps the correct build'
do
described_class
.
update!
(
events
,
from:
'id'
,
to:
'build'
,
klass:
::
Ci
::
Build
)
expect
(
events
.
first
[
'build'
]).
to
eq
(
build
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录