2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-16 03:58:23 -05:00
|
|
|
module Projects
|
|
|
|
module CycleAnalytics
|
2016-11-16 06:01:10 -05:00
|
|
|
class EventsController < Projects::ApplicationController
|
|
|
|
include CycleAnalyticsParams
|
2020-07-17 14:09:20 -04:00
|
|
|
include GracefulTimeoutHandling
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-11-16 06:01:10 -05:00
|
|
|
before_action :authorize_read_cycle_analytics!
|
2016-11-18 07:00:38 -05:00
|
|
|
before_action :authorize_read_build!, only: [:test, :staging]
|
2016-11-18 06:05:29 -05:00
|
|
|
before_action :authorize_read_issue!, only: [:issue, :production]
|
|
|
|
before_action :authorize_read_merge_request!, only: [:code, :review]
|
|
|
|
|
2020-10-08 14:08:32 -04:00
|
|
|
feature_category :planning_analytics
|
|
|
|
|
2016-11-16 06:01:10 -05:00
|
|
|
def issue
|
2016-12-01 05:21:24 -05:00
|
|
|
render_events(cycle_analytics[:issue].events)
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-11-16 06:01:10 -05:00
|
|
|
def plan
|
2016-12-01 05:21:24 -05:00
|
|
|
render_events(cycle_analytics[:plan].events)
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-11-16 06:01:10 -05:00
|
|
|
def code
|
2016-12-01 05:21:24 -05:00
|
|
|
render_events(cycle_analytics[:code].events)
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-11-16 06:01:10 -05:00
|
|
|
def test
|
2019-10-07 17:07:54 -04:00
|
|
|
options(cycle_analytics_project_params)[:branch] = cycle_analytics_project_params[:branch_name]
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-12-01 05:21:24 -05:00
|
|
|
render_events(cycle_analytics[:test].events)
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-11-16 06:01:10 -05:00
|
|
|
def review
|
2016-12-01 05:21:24 -05:00
|
|
|
render_events(cycle_analytics[:review].events)
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-11-16 06:01:10 -05:00
|
|
|
def staging
|
2016-12-01 05:21:24 -05:00
|
|
|
render_events(cycle_analytics[:staging].events)
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-11-16 06:01:10 -05:00
|
|
|
def production
|
2016-12-01 05:21:24 -05:00
|
|
|
render_events(cycle_analytics[:production].events)
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-11-16 06:01:10 -05:00
|
|
|
private
|
2016-11-23 05:28:28 -05:00
|
|
|
|
|
|
|
def render_events(events)
|
2016-11-16 06:01:10 -05:00
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
2016-11-23 05:28:28 -05:00
|
|
|
format.json { render json: { events: events } }
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
|
|
|
end
|
2017-08-15 13:44:37 -04:00
|
|
|
|
2016-11-23 05:28:28 -05:00
|
|
|
def cycle_analytics
|
2019-10-07 17:07:54 -04:00
|
|
|
@cycle_analytics ||= ::CycleAnalytics::ProjectLevel.new(project, options: options(cycle_analytics_project_params))
|
2016-11-16 06:01:10 -05:00
|
|
|
end
|
2016-10-24 10:24:56 -04:00
|
|
|
end
|
|
|
|
end
|
2016-10-27 12:52:42 -04:00
|
|
|
end
|