Commit cfc4e738 authored by ggelatti's avatar ggelatti

Refactor package event list generation

- refactor the code to ease follow up MR
- sort events list for clarity when introducing new events
parent d59352ae
...@@ -18,12 +18,12 @@ namespace :gitlab do ...@@ -18,12 +18,12 @@ namespace :gitlab do
end end
def event_pairs def event_pairs
::Packages::Event.event_types.keys.product(::Packages::Event.originator_types.keys) ::Packages::Event.event_types.keys.product(::Packages::Event::EVENT_SCOPES.keys)
end end
def generate_unique_events_list def generate_unique_events_list
::Packages::Event::EVENT_SCOPES.keys.each_with_object([]) do |event_scope, events| events = event_pairs.each_with_object([]) do |(event_type, event_scope), events|
event_pairs.each do |event_type, originator| ::Packages::Event.originator_types.keys.excluding('guest').each do |originator|
if name = ::Packages::Event.allowed_event_name(event_scope, event_type, originator) if name = ::Packages::Event.allowed_event_name(event_scope, event_type, originator)
events << { events << {
"name" => name, "name" => name,
...@@ -35,6 +35,8 @@ namespace :gitlab do ...@@ -35,6 +35,8 @@ namespace :gitlab do
end end
end end
end end
events.sort_by { |event| event["name"] }
end end
end 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