From d4726112656df24ff7721865a96237d5168466f7 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Mon, 24 Oct 2016 15:24:56 +0100 Subject: added cycle analytics events controller and started integration spec --- .../projects/cycle_analytics/events_controller.rb | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/controllers/projects/cycle_analytics/events_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/projects/cycle_analytics/events_controller.rb b/app/controllers/projects/cycle_analytics/events_controller.rb new file mode 100644 index 00000000000..fe0135874b9 --- /dev/null +++ b/app/controllers/projects/cycle_analytics/events_controller.rb @@ -0,0 +1,34 @@ +class Projects::CycleAnalytics::EventsController < Projects::ApplicationController + #before_action :authorize_read_cycle_analytics! + + def issues + respond_to do |format| + format.html + format.json { render json: events.issue_events } + end + end + + private + + # TODO refactor this + def start_date + case events_params[:start_date] + when '30' then + 30.days.ago + when '90' then + 90.days.ago + else + 90.days.ago + end + end + + def events + @events ||= Gitlab::CycleAnalytics::Events.new(project: project, from: start_date) + end + + def events_params + return {} unless params[:events].present? + + { start_date: params[:events][:start_date] } + end +end \ No newline at end of file -- cgit v1.2.1