Expose Cycle Analytics median and records via API
What does this MR do?
This MR exposes to the frontend the median and the related records calculated for a given stage. The query and the classes that produce the values / records have been reviewed and merged in earlier MRs. FE will integrate these APIs to render the new CA page.
The RequestParams
class is used for validating incoming query parameters and provide error messages to the FE. More info: #32759 (closed)
To try the feature, make sure that you enable the FF:
Feature.enable(:cycle_analytics)
Example Endpoint With a Default Stage:
-/analytics/cycle_analytics/stages/review/records?group_id=gitlab-org&created_after=2019-01-01&created_before=2019-05-01
Example Endpoint With a Persisted Stage:
In rails console:
group = Group.find_by_full_path("gitlab-org")
user = User.find_by_username("root")
Analytics::CycleAnalytics::Stages::CreateService.new(parent: group, params: { name: 'My Stage', start_event_identifier: :merge_request_created, end_event_identifier: :merge_request_merged }, current_user: user).execute
puts Analytics::CycleAnalytics::GroupStage.find_by_name("My Stage").id
Use the printed id
in the URL:
-/analytics/cycle_analytics/stages/$STAGE_ID/records?group_id=gitlab-org&created_after=2019-01-01&created_before=2019-05-01
Invalid URL params:
-/analytics/cycle_analytics/stages/review/records?group_id=countgroup&created_after=2019-01-01&created_before=2018-01-01
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related Issue: #12196 (closed)