2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Projects
|
|
|
|
module CycleAnalytics
|
|
|
|
class EventsController < Projects::ApplicationController
|
|
|
|
include CycleAnalyticsParams
|
2020-10-24 23:57:45 +05:30
|
|
|
include GracefulTimeoutHandling
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
before_action :authorize_read_cycle_analytics!
|
|
|
|
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]
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
feature_category :planning_analytics
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def issue
|
|
|
|
render_events(cycle_analytics[:issue].events)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def plan
|
|
|
|
render_events(cycle_analytics[:plan].events)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def code
|
|
|
|
render_events(cycle_analytics[:code].events)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def test
|
2019-12-21 20:55:43 +05:30
|
|
|
options(cycle_analytics_project_params)[:branch] = cycle_analytics_project_params[:branch_name]
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
render_events(cycle_analytics[:test].events)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def review
|
|
|
|
render_events(cycle_analytics[:review].events)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def staging
|
|
|
|
render_events(cycle_analytics[:staging].events)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def production
|
|
|
|
render_events(cycle_analytics[:production].events)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def render_events(events)
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json { render json: { events: events } }
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def cycle_analytics
|
2019-12-21 20:55:43 +05:30
|
|
|
@cycle_analytics ||= ::CycleAnalytics::ProjectLevel.new(project, options: options(cycle_analytics_project_params))
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|