Skip to content

Add search capabilities for the project count component

Zamir Martins requested to merge add_search_for_project_component into master

What does this MR do and why?

Add search capabilities for the project count component under dependency list. Related design.

EE: true Changelog: changed

Related issue: #409071 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

search_project_v2

Graphql query

query {
  group(fullPath: $fullPath){
    projects(sbomComponentId: $sbomComponentId, includeSubgroups: $includeSubgroups, search: $search, first: $first) {
      nodes{
        id
        name
        avatarUrl
        fullPath
      }
    }
  }
}

Query plan

Link to the query plan

SELECT
  "projects".*,
  ROUND(CAST(((SIMILARITY(COALESCE("projects"."path", ''), 'backend') * CAST('1' AS numeric)) + (SIMILARITY(COALESCE("projects"."name", ''), 'backend') * CAST('0.7' AS numeric)) + (SIMILARITY(COALESCE("projects"."description", ''), 'backend') * CAST('0.2' AS numeric))) AS numeric), 2) AS similarity
FROM "projects"
WHERE "projects"."namespace_id" IN (
  SELECT namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)] AS id
  FROM "namespaces"
  WHERE "namespaces"."type" = 'Group'
  AND (traversal_ids @> ('{68248292}'))
)
AND (("projects"."path" ILIKE '%backend%' OR "projects"."name" ILIKE '%backend%') OR "projects"."description" ILIKE '%backend%')
AND "projects"."id" IN (
  SELECT "sbom_occurrences"."project_id"
  FROM "sbom_occurrences"
  WHERE "sbom_occurrences"."component_id" = 211382)
ORDER BY ROUND(CAST(((SIMILARITY(COALESCE("projects"."path", ''), 'backend') * CAST('1' AS numeric)) + (SIMILARITY(COALESCE("projects"."name", ''), 'backend') * CAST('0.7' AS numeric)) + (SIMILARITY(COALESCE("projects"."description", ''), 'backend') * CAST('0.2' AS numeric))) AS numeric), 2) DESC, "projects"."id" DESC
LIMIT 51

How to set up and validate locally

  1. Fetch the content of both branches: add_search_for_project_component .
  2. Turn on the feature flag to make Dependency list appear in groups:
echo "Feature.enable(:group_level_dependencies)" | rails c
  1. Create two projects under a group with the following content:
  • .gitlab-ci.yml:
include:
  - template: Security/Dependency-Scanning.gitlab-ci.yml
  1. Run a pipeline for the default branch to both projects
  2. Go group related to the projects created above and click on the menu option Secure -> Dependency list

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Zamir Martins

Merge request reports