Commit 9901c3df authored by Timothy Andrew's avatar Timothy Andrew

Add a JSON version of the `CycleAnalytics` page.

parent f5b9837c
......@@ -3,6 +3,11 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
def show
@cycle_analytics = CycleAnalytics.new(@project, from: parse_start_date)
respond_to do |format|
format.html
format.json { render json: @cycle_analytics }
end
end
private
......
......@@ -6,6 +6,13 @@ class CycleAnalytics
@from = from
end
def as_json(options = {})
{
issue: issue, plan: plan, code: code, test: test,
review: review, staging: staging, production: production
}
end
def issue
calculate_metric(Queries::issues(@project, created_after: @from),
-> (data_point) { data_point[:issue].created_at },
......
......@@ -101,6 +101,7 @@ class ProjectPolicy < BasePolicy
can! :admin_pipeline
can! :admin_environment
can! :admin_deployment
can! :read_cycle_analytics
end
def public_access!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment