Add a JSON version of the `CycleAnalytics` page.
This commit is contained in:
parent
f5b9837c19
commit
9901c3df41
|
@ -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!
|
||||
|
|
Loading…
Reference in New Issue