Add sorting based on project star as default sort for CI components
What does this MR do and why?
Adds default sorting based on star count for catalog resources.
Adds spec for the sorting ability in the model.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
How to set up and validate locally
- Seed the db with catalog resources using
bundle exec rake "gitlab:seed:ci_catalog_resources[Flightjs, 12, true]"
. This adds 12 components. - Update stars for the projects associated with these resources using the below short script, which you can run in the rails console.
p_ids=Ci::Catalog::Resource.all.pluck(:project_id)
p_ids.each do |p_id|
p = Project.find_by(id: p_id)
p.star_count = rand(100)
p.save!
end
This will update the projects with random star counts between 0 to 100.
- Go to
/explore/catalog
on your local gdk and see the resources sorted in descending order by star count.
Related to #437897 (closed)
Edited by Rajendra Kadam