Project Search sort based on algorithmic score
The Project Search dropdown currently sorts by project.created_at, then project.id (taken from the performance bar. There is a param called order_by
which if set to similarity
will use a weighted algorithm to sort the projects returned: see the reorder_projects_with_similarity_order_support
method in lib/api/groups.rb. This may be enough to fix the sorting of projects returned in the dropdown (and may be a frontend fix vs. a backend fix). I'm adding both labels and you can remove one of them once the MR is created.
current sql
/*application:web,correlation_id:01F7KWW7YB5A5JJF0SHE591PKS,endpoint_id:GET /api/:version/groups/:id/projects*/
SELECT
"projects".*
FROM ((
SELECT
"projects".*
FROM
"projects"
WHERE
"projects"."namespace_id" = 9970
AND (EXISTS (
SELECT
1
FROM
"project_authorizations"
WHERE
"project_authorizations"."user_id" = 5708766
AND (project_authorizations.project_id = projects.id))
OR projects.visibility_level IN (10, 20)))
UNION (
SELECT
"projects".*
FROM
"projects"
INNER JOIN "project_group_links" ON "projects"."id" = "project_group_links"."project_id"
WHERE
"project_group_links"."group_id" = 9970
AND (EXISTS (
SELECT
1
FROM
"project_authorizations"
WHERE
"project_authorizations"."user_id" = 5708766
AND (project_authorizations.project_id = projects.id))
OR projects.visibility_level IN (10, 20)))) projects
WHERE (("projects"."path" ILIKE '%test%'
OR "projects"."name" ILIKE '%test%')
OR "projects"."description" ILIKE '%test%')
AND "projects"."pending_delete" = FALSE
ORDER BY
"projects"."created_at" DESC,
"projects"."id" DESC
LIMIT 20 OFFSET 0
Plan
The Project search dropdown has two modes:
- Any Group selected
- Specific Group selected
I'll open an MR for each as the solutions are not identical, but both will rely upon sorting by similarity scopes that are exposed.
Edited by Terri Chu