Skip to content

Add pagination for VSA records

Adam Hegyi requested to merge 324075-vsa-pagination into master

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

  1. Make sure you have ultimate plan.
  2. 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
  3. Go to the generated group page: Analytics / Value Stream
  4. Open the network inspector and look for json requests
  5. Open the first stage: Plan
  6. Check if the records.json request includes the <Link> header
  7. Copy the next page link, it should return data for the next page

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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)

Edited by Adam Hegyi

Merge request reports

Loading