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
|
def show
|
||||||
@cycle_analytics = CycleAnalytics.new(@project, from: parse_start_date)
|
@cycle_analytics = CycleAnalytics.new(@project, from: parse_start_date)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.json { render json: @cycle_analytics }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -6,6 +6,13 @@ class CycleAnalytics
|
||||||
@from = from
|
@from = from
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_json(options = {})
|
||||||
|
{
|
||||||
|
issue: issue, plan: plan, code: code, test: test,
|
||||||
|
review: review, staging: staging, production: production
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def issue
|
def issue
|
||||||
calculate_metric(Queries::issues(@project, created_after: @from),
|
calculate_metric(Queries::issues(@project, created_after: @from),
|
||||||
-> (data_point) { data_point[:issue].created_at },
|
-> (data_point) { data_point[:issue].created_at },
|
||||||
|
|
|
@ -101,6 +101,7 @@ class ProjectPolicy < BasePolicy
|
||||||
can! :admin_pipeline
|
can! :admin_pipeline
|
||||||
can! :admin_environment
|
can! :admin_environment
|
||||||
can! :admin_deployment
|
can! :admin_deployment
|
||||||
|
can! :read_cycle_analytics
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_access!
|
def public_access!
|
||||||
|
|
Loading…
Reference in New Issue