Skip to content
Snippets Groups Projects

Adds API support for Project Deployment Frequency

Merged Amy Troschinetz requested to merge api-support-for-deployment-frequency into master
Compare and
5 files
+ 139
0
Compare changes
  • Side-by-side
  • Inline
Files
5
# frozen_string_literal: true
module API
module Analytics
class ProjectCycleAnalytics < ::API::Base
include PaginationParams
feature_category :planning_analytics
before do
authenticate!
end
resource :analytics do
desc 'List cycle analytics information about project'
params do
requires :project_id, type: Integer, desc: 'Project ID'
# TODO: Required parameter: From
# TODO: Optional parameter: To? Default: Now.
# TODO: Optional parameter: rollup interval? Default: 30 Days.
use :pagination
end
get 'deployment_frequency' do
authorize! :read_project_cycle_analytics, user_project
# TODO: Rollup the data by the given interval, default 30 days.
deploy = Gitlab::Analytics::CycleAnalytics::Summary::Group::Deploy.new(
project: project.group,
options: {
# from: ???,
# to: ???
}
)
# TODO: What should this data look like when we roll it up by our interval?
# Something like this?
#
# {
# value: NUMBER,
# start: DATE,
# end: DATE
# }
#
# Where the days between `start` to `end` is the length of our interval?
data = [{ value: deploy.value }]
deployment_frequencies = paginate(data)
present deployment_frequencies,
with: EE::API::Entities::Analytics::Cycle::DeploymentFrequency,
current_user: current_user,
issuable_metadata: Gitlab::IssuableMetadata.new(current_user, deployment_frequencies).data
end
end
end
end
end
Loading