Update report sorting to generic keyset pagination
What does this MR do and why?
This MR changes the Vulnerabilities sorting by report type to use the generic keyset pagination library.
Note: this is not a user-facing change.
Related issue: #341286 (closed)
Context:
We built a new keyset pagination library where we have more flexibility for defining ORDER BY clauses. It also fixes a few sorting bugs when multiple columns are used for the sorting.
The new keyset pagination library can detect simple ORDER BY clauses and automagically work with existing ActiveRecord scopes. The feature flag for this change is already enabled globally however, there are a few AR scopes where this automatic conversion is not possible. Sorting by report_type is one of the special cases because it uses a CASE statement: https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/models/ee/vulnerability.rb#L237
When the automatic conversion is not possible, the GraphQL connection will fall back to the old keyset pagination code: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/graphql/pagination/keyset/generic_keyset_pagination.rb#L71
To make the AR scope keyset pagination aware, we build a custom order object on the model level.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.