Skip to content

Add sorting based on project star as default sort for CI components

Rajendra Kadam requested to merge 437897-sort-default-star-catalog into master

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

Screenshot_2024-02-14_at_11.26.06_PM

How to set up and validate locally

  1. Seed the db with catalog resources using bundle exec rake "gitlab:seed:ci_catalog_resources[Flightjs, 12, true]". This adds 12 components.
  2. 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.

  1. 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

Merge request reports