gitlab-org--gitlab-foss/app/controllers/projects/cycle_analytics/events_controller.rb

62 lines
1.5 KiB
Ruby
Raw Normal View History

module Projects
module CycleAnalytics
class EventsController < Projects::ApplicationController
include CycleAnalyticsParams
before_action :authorize_read_cycle_analytics!
2016-11-18 07:00:38 -05:00
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]
def issue
render_events(cycle_analytics[:issue].events)
end
def plan
render_events(cycle_analytics[:plan].events)
end
def code
render_events(cycle_analytics[:code].events)
end
def test
2016-11-23 05:28:28 -05:00
options(events_params)[:branch] = events_params[:branch_name]
render_events(cycle_analytics[:test].events)
end
def review
render_events(cycle_analytics[:review].events)
end
def staging
render_events(cycle_analytics[:staging].events)
end
def production
render_events(cycle_analytics[:production].events)
end
private
2016-11-23 05:28:28 -05:00
def render_events(events)
respond_to do |format|
format.html
2016-11-23 05:28:28 -05:00
format.json { render json: { events: events } }
end
end
2016-11-23 05:28:28 -05:00
def cycle_analytics
2016-12-01 06:44:35 -05:00
@cycle_analytics ||= ::CycleAnalytics.new(project, options(events_params))
end
def events_params
return {} unless params[:events].present?
params[:events].permit(:start_date, :branch_name)
end
end
end
end