Add pagination for VSA records
What does this MR do?
This MR adds pagination to the value stream record list and also exposes standard API pagination headers via the controller action.
How:
Gitlab::Analytics::CycleAnalytics::RecordsFetcher
is responsible for loading the relevant records in a serialized format. Before this MR, we took maximum 20 records. With this MR, we apply pagination based on the incoming page
param.
The class is invoked via an API call where we need to expose extra headers for the pagination (for example link to the next page) so the FE can build the pagination links. The API is private and only used by the frontend. For the REST API we already have a standard way for exposing these headers by inspecting the AR relation, however it doesn't work with standard rails controllers out of the box.
This MR also includes an extra if check so we can reuse the OffsetPagination
class in controller actions:
- Grape context has a
header
method for adding header. - Rails controller context has a
response.headers
hash.
How to test it
- Make sure you have ultimate plan.
- Run the seed script to generate a group with a lot's of issues:
VSA_ISSUE_COUNT=100 SEED_VSA=true FILTER=cycle_analytics rake db:seed_fu
- Go to the generated group page: Analytics / Value Stream
- Open the network inspector and look for json requests
- Open the first stage: Plan
- Check if the
records.json
request includes the<Link>
header - Copy the next page link, it should return data for the next page
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because the change is not user facing (FE implementation is needed).
-
-
Documentation (if required) -
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 -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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 to #324075 (closed)