Add latest_released_at sort options to GraphQL ciCatalogResources
What does this MR do and why?
In !132429 (merged), we added the latest_released_at
column to catalog_resources
.
This MR adds the option to sort by latest_released_at
for the GraphQL ciCatalogResources
endpoint.
Note that the column is always null
for now. It will be updated via services described in Step 3 of #408382 (closed). You will have to manually update the column via the Rails console for testing purposes.
Resolves Step 2 of #408382 (closed).
How to set up and validate locally
- Created 3 catalog resources.
- In the Rails console, update one of the resources with today's date and another with yesterday's date. Leave the third resource with a NULL
latest_released_at
value.
resource1.update!(latest_released_at: Time.zone.now)
resource2.update!(latest_released_at: Time.zone.now - 1.day)
- In
http://gdk.test:3000/-/graphql-explorer
, test the following query:
query getCiCatalogResources {
ciCatalogResources(sort: LATEST_RELEASED_AT_DESC, projectPath: "group-a/project-catalog-resource-1") {
nodes {
name
latestReleasedAt
}
}
}
- Observe the output. It should show the resources ordered by
latest_released_at
descending with the NULL value last.
- Update the query with
LATEST_RELEASED_AT_ASC
and confirm the output is as expected.
- (Optional) You can also confirm that the pagination works as expected. Example:
query getCiCatalogResources {
ciCatalogResources(after: null, first: 1, sort: LATEST_RELEASED_AT_DESC, projectPath: "group-a/project-catalog-resource-1") {
nodes {
name
latestReleasedAt
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
Query plans
SELECT "catalog_resources".* FROM "catalog_resources" ORDER BY "catalog_resources"."latest_released_at" DESC NULLS LAST
SELECT "catalog_resources".* FROM "catalog_resources" ORDER BY "catalog_resources"."latest_released_at" ASC NULLS LAST
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 #408382 (closed)
Edited by Leaminn Ma