Backend: Add option to sort CI catalog resources by usage count in GraphQl
Summary
One of our objectives with CI Catalog instrumentation is to enable users to sort Catalog Resources (aka "Catalog Projects") by popularity (usage count).
The bulk of the BE work to support this feature was done as part of #440382 (closed). In !147293 (merged), we introduced the columns last_30_day_usage_count
and last_30_day_usage_count_updated_at
to the catalog_resources
table. These columns will be populated by the effort in Backend: Implement daily worker to aggregate la... (#452545 - closed).
In this issue, we need to expose last_30_day_usage_count
and add the option to sort by usage in GraphQl.
Proposal
Add USAGE_COUNT_ASC
AND USAGE_COUNT_DESC
as sort options to Ci::Catalog::ResourceType
. Also, expose the last_30_day_usage_count
column.
We should be able to query the catalog resources like so:
Sort catalog resources by usage count
query getSortedCatalogResources {
ciCatalogResources(sort: USAGE_COUNT_DESC) {
nodes {
id
last30DayUsageCount
}
}
}