debian-mirror-gitlab/app/serializers/analytics/cycle_analytics/event_entity.rb
2021-06-08 01:23:25 +05:30

37 lines
806 B
Ruby

# frozen_string_literal: true
module Analytics
module CycleAnalytics
class EventEntity < Grape::Entity
expose :name
expose :identifier
expose :type
expose :can_be_start_event?, as: :can_be_start_event
expose :allowed_end_events
private
def type
object.label_based? ? 'label' : 'simple'
end
def can_be_start_event?
pairing_rules.has_key?(object)
end
def allowed_end_events
pairing_rules.fetch(object, []).map do |event|
event.identifier unless stage_events.internal_events.include?(event)
end.compact
end
def pairing_rules
stage_events.pairing_rules
end
def stage_events
Gitlab::Analytics::CycleAnalytics::StageEvents
end
end
end
end