Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e139d7af
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,发现更多精彩内容 >>
未验证
提交
e139d7af
编写于
2月 26, 2018
作者:
R
Rémy Coutable
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix a performance/memory issue in lib/api/services.rb
Signed-off-by:
N
Rémy Coutable
<
remy@rymai.me
>
上级
e0195f33
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
42 deletion
+42
-42
lib/api/services.rb
lib/api/services.rb
+42
-42
未找到文件。
lib/api/services.rb
浏览文件 @
e139d7af
# frozen_string_literal: true
module
API
class
Services
<
Grape
::
API
chat_notification_settings
=
[
CHAT_NOTIFICATION_SETTINGS
=
[
{
required:
true
,
name: :webhook
,
...
...
@@ -19,9 +20,9 @@ module API
type:
String
,
desc:
'The default chat channel'
}
]
]
.
freeze
chat_notification_flags
=
[
CHAT_NOTIFICATION_FLAGS
=
[
{
required:
false
,
name: :notify_only_broken_pipelines
,
...
...
@@ -34,9 +35,9 @@ module API
type:
Boolean
,
desc:
'Send notifications only for the default branch'
}
]
]
.
freeze
chat_notification_channels
=
[
CHAT_NOTIFICATION_CHANNELS
=
[
{
required:
false
,
name: :push_channel
,
...
...
@@ -85,9 +86,9 @@ module API
type:
String
,
desc:
'The name of the channel to receive wiki_page_events notifications'
}
]
]
.
freeze
chat_notification_events
=
[
CHAT_NOTIFICATION_EVENTS
=
[
{
required:
false
,
name: :push_events
,
...
...
@@ -136,9 +137,9 @@ module API
type:
Boolean
,
desc:
'Enable notifications for wiki_page_events'
}
]
]
.
freeze
services
=
{
SERVICES
=
{
'asana'
=>
[
{
required:
true
,
...
...
@@ -627,10 +628,10 @@ module API
}
],
'slack'
=>
[
chat_notification_settings
,
chat_notification_flags
,
chat_notification_channels
,
chat_notification_events
CHAT_NOTIFICATION_SETTINGS
,
CHAT_NOTIFICATION_FLAGS
,
CHAT_NOTIFICATION_CHANNELS
,
CHAT_NOTIFICATION_EVENTS
].
flatten
,
'microsoft-teams'
=>
[
{
...
...
@@ -641,10 +642,10 @@ module API
}
],
'mattermost'
=>
[
chat_notification_settings
,
chat_notification_flags
,
chat_notification_channels
,
chat_notification_events
CHAT_NOTIFICATION_SETTINGS
,
CHAT_NOTIFICATION_FLAGS
,
CHAT_NOTIFICATION_CHANNELS
,
CHAT_NOTIFICATION_EVENTS
].
flatten
,
'teamcity'
=>
[
{
...
...
@@ -672,9 +673,9 @@ module API
desc:
'The password of the user'
}
]
}
}
.
freeze
service_classes
=
[
SERVICE_CLASSES
=
[
AsanaService
,
AssemblaService
,
BambooService
,
...
...
@@ -703,10 +704,10 @@ module API
MattermostService
,
MicrosoftTeamsService
,
TeamcityService
]
]
.
freeze
if
Rails
.
env
.
development?
services
[
'mock-ci'
]
=
[
SERVICES
[
'mock-ci'
]
=
[
{
required:
true
,
name: :mock_service_url
,
...
...
@@ -714,17 +715,29 @@ module API
desc:
'URL to the mock service'
}
]
services
[
'mock-deployment'
]
=
[]
services
[
'mock-monitoring'
]
=
[]
SERVICES
[
'mock-deployment'
]
=
[]
SERVICES
[
'mock-monitoring'
]
=
[]
service_classes
+=
[
SERVICE_CLASSES
+=
[
MockCiService
,
MockDeploymentService
,
MockMonitoringService
]
end
trigger_services
=
{
SERVICE_CLASSES
.
each
do
|
service
|
event_names
=
service
.
try
(
:event_names
)
||
next
event_names
.
each
do
|
event_name
|
SERVICES
[
service
.
to_param
.
tr
(
"_"
,
"-"
)]
<<
{
required:
false
,
name:
event_name
.
to_sym
,
type:
String
,
desc:
ServicesHelper
.
service_event_description
(
event_name
)
}
end
end
TRIGGER_SERVICES
=
{
'mattermost-slash-commands'
=>
[
{
name: :token
,
...
...
@@ -756,22 +769,9 @@ module API
end
end
services
.
each
do
|
service_slug
,
settings
|
SERVICES
.
each
do
|
service_slug
,
settings
|
desc
"Set
#{
service_slug
}
service for project"
params
do
service_classes
.
each
do
|
service
|
event_names
=
service
.
try
(
:event_names
)
||
next
event_names
.
each
do
|
event_name
|
services
[
service
.
to_param
.
tr
(
"_"
,
"-"
)]
<<
{
required:
false
,
name:
event_name
.
to_sym
,
type:
String
,
desc:
ServicesHelper
.
service_event_description
(
event_name
)
}
end
end
services
.
freeze
settings
.
each
do
|
setting
|
if
setting
[
:required
]
requires
setting
[
:name
],
type:
setting
[
:type
],
desc:
setting
[
:desc
]
...
...
@@ -794,7 +794,7 @@ module API
desc
"Delete a service for project"
params
do
requires
:service_slug
,
type:
String
,
values:
services
.
keys
,
desc:
'The name of the service'
requires
:service_slug
,
type:
String
,
values:
SERVICES
.
keys
,
desc:
'The name of the service'
end
delete
":id/services/:service_slug"
do
service
=
user_project
.
find_or_initialize_service
(
params
[
:service_slug
].
underscore
)
...
...
@@ -814,7 +814,7 @@ module API
success
Entities
::
ProjectService
end
params
do
requires
:service_slug
,
type:
String
,
values:
services
.
keys
,
desc:
'The name of the service'
requires
:service_slug
,
type:
String
,
values:
SERVICES
.
keys
,
desc:
'The name of the service'
end
get
":id/services/:service_slug"
do
service
=
user_project
.
find_or_initialize_service
(
params
[
:service_slug
].
underscore
)
...
...
@@ -822,7 +822,7 @@ module API
end
end
trigger_services
.
each
do
|
service_slug
,
settings
|
TRIGGER_SERVICES
.
each
do
|
service_slug
,
settings
|
helpers
do
def
slash_command_service
(
project
,
service_slug
,
params
)
project
.
services
.
active
.
where
(
template:
false
).
find
do
|
service
|
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录