Update CI catalog resources name sort to use denormalized column
What does this MR do and why?
In !134708 (merged) we denormalized the columns name
and description
from the projects
table and added them to the catalog_resources
table (along with trigram indexes on both columns). Now we can use these columns directly instead of relying on JOIN-ing with the projects
table.
We can also remove Project.sorted_by_name_desc
and Project.sorted_by_name_asc
. They were originally introduced in !118802 (diffs) in order to support keyset pagination with the .merge
operation. With this MR, we no longer need them to serve that purpose. Both methods are also not used anywhere else so we can remove it.
Resolves Step 3 of #427928 (closed).
Query plan
SELECT "catalog_resources".* FROM "catalog_resources" ORDER BY "catalog_resources"."name" DESC NULLS LAST
Query plan link:
Query plan for ASC
is the same ^.
How to set up and validate locally
- Under the same parent group, create 3 projects with README files and any description, named:
AA Project
,BB Project
, andCC Project
. - In the console, convert projects to catalog resources in the following order:
Ci::Catalog::Resource.create!(project: Project.find_by(name: 'AA Project'))
Ci::Catalog::Resource.create!(project: Project.find_by(name: 'CC Project'))
Ci::Catalog::Resource.create!(project: Project.find_by(name: 'BB Project'))
- Go to
http://gdk.test:3000/
and test the following query (update the group name as necessary; usescope: "all"
if it has replacedprojectPath
by now.):
query {
ciCatalogResources(projectPath: "group-a/aa-project") {
nodes {
id
name
}
}
}
Observe that the resources are returned in the following order:
- Now add a sort argument to the query:
query {
ciCatalogResources(projectPath: "group-a/aa-project", sort: NAME_ASC) {
nodes {
id
name
}
}
}
Observe that the resources are returned in ascending alphabetical order.
- Update the sort parameter to
NAME_DESC
. Observe that the resources are returned in descending alphabetical order.
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.
Related to #427928 (closed)