debian-mirror-gitlab/app/controllers/projects/cycle_analytics_controller.rb

35 lines
862 B
Ruby
Raw Normal View History

2016-09-29 09:46:39 +05:30
class Projects::CycleAnalyticsController < Projects::ApplicationController
include ActionView::Helpers::DateHelper
include ActionView::Helpers::TextHelper
2017-08-17 22:00:37 +05:30
include CycleAnalyticsParams
2016-09-29 09:46:39 +05:30
before_action :authorize_read_cycle_analytics!
def show
2017-08-17 22:00:37 +05:30
@cycle_analytics = ::CycleAnalytics.new(@project, options(cycle_analytics_params))
@cycle_analytics_no_data = @cycle_analytics.no_stats?
2016-09-29 09:46:39 +05:30
respond_to do |format|
format.html
format.json { render json: cycle_analytics_json }
end
end
private
def cycle_analytics_params
return {} unless params[:cycle_analytics].present?
2017-08-17 22:00:37 +05:30
params[:cycle_analytics].permit(:start_date)
2016-09-29 09:46:39 +05:30
end
def cycle_analytics_json
{
2017-08-17 22:00:37 +05:30
summary: @cycle_analytics.summary,
stats: @cycle_analytics.stats,
permissions: @cycle_analytics.permissions(user: current_user)
2016-09-29 09:46:39 +05:30
}
end
end