Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 44,761
    • Issues 44,761
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,329
    • Merge requests 1,329
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #332890
Closed
Open
Issue created Jun 07, 2021 by Terri Chu@terrichu2️⃣Maintainer

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:

  1. Any Group selected
  2. 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 Jun 17, 2021 by Terri Chu
Assignee
Assign to
Time tracking