Commit 7f0b4ce1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Split complex method SystemHooksService#build_event_data

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent e5cc197a
...@@ -33,17 +33,7 @@ class SystemHooksService ...@@ -33,17 +33,7 @@ class SystemHooksService
) )
end end
when Project when Project
owner = model.owner data.merge!(project_data(model))
data.merge!({
name: model.name,
path: model.path,
path_with_namespace: model.path_with_namespace,
project_id: model.id,
owner_name: owner.name,
owner_email: owner.respond_to?(:email) ? owner.email : "",
project_visibility: Project.visibility_levels.key(model.visibility_level_field).downcase
})
when User when User
data.merge!({ data.merge!({
name: model.name, name: model.name,
...@@ -51,16 +41,7 @@ class SystemHooksService ...@@ -51,16 +41,7 @@ class SystemHooksService
user_id: model.id user_id: model.id
}) })
when ProjectMember when ProjectMember
data.merge!({ data.merge!(project_member_data(model))
project_name: model.project.name,
project_path: model.project.path,
project_path_with_namespace: model.project.path_with_namespace,
project_id: model.project.id,
user_name: model.user.name,
user_email: model.user.email,
access_level: model.human_access,
project_visibility: Project.visibility_levels.key(model.project.visibility_level_field).downcase
})
when Group when Group
owner = model.owner owner = model.owner
...@@ -72,15 +53,7 @@ class SystemHooksService ...@@ -72,15 +53,7 @@ class SystemHooksService
owner_email: owner.respond_to?(:email) ? owner.email : nil, owner_email: owner.respond_to?(:email) ? owner.email : nil,
) )
when GroupMember when GroupMember
data.merge!( data.merge!(group_member_data(model))
group_name: model.group.name,
group_path: model.group.path,
group_id: model.group.id,
user_name: model.user.name,
user_email: model.user.email,
user_id: model.user.id,
group_access: model.human_access,
)
end end
end end
...@@ -96,4 +69,43 @@ class SystemHooksService ...@@ -96,4 +69,43 @@ class SystemHooksService
"#{model.class.name.downcase}_#{event.to_s}" "#{model.class.name.downcase}_#{event.to_s}"
end end
end end
def project_data(model)
owner = model.owner
{
name: model.name,
path: model.path,
path_with_namespace: model.path_with_namespace,
project_id: model.id,
owner_name: owner.name,
owner_email: owner.respond_to?(:email) ? owner.email : "",
project_visibility: Project.visibility_levels.key(model.visibility_level_field).downcase
}
end
def project_member_data(model)
{
project_name: model.project.name,
project_path: model.project.path,
project_path_with_namespace: model.project.path_with_namespace,
project_id: model.project.id,
user_name: model.user.name,
user_email: model.user.email,
access_level: model.human_access,
project_visibility: Project.visibility_levels.key(model.project.visibility_level_field).downcase
}
end
def group_member_data(model)
{
group_name: model.group.name,
group_path: model.group.path,
group_id: model.group.id,
user_name: model.user.name,
user_email: model.user.email,
user_id: model.user.id,
group_access: model.human_access,
}
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment