Fix empty dependency list page

What does this MR do and why?

Fix empty dependency list page

Prevent deletion of occurrence when container_scanning_for_registry report is ingested.

Changes:

  1. Prevent deletion of other sbom occurrences when container_scanning_for_registry occurrences are ingested.
  2. Prevent deletion of container_scanning_for_registry occurrence when other sbom occurrences are ingested.

other sbom occurrences: Sbom occurrences with source type = [:dependency_scanning, :container_scanning, nil]

Changelog: fixed EE: true

Query plan

before

Click to expand
DELETE FROM sbom_occurrences
WHERE
    sbom_occurrences.project_id = 2 AND
    sbom_occurrences.id NOT IN ( 6, 7 ) AND
    sbom_occurrences.id >= 5;

after

Click to expand
DELETE FROM sbom_occurrences
WHERE
    sbom_occurrences.id IN (
        SELECT
            sbom_occurrences.id
        FROM
            sbom_occurrences
            LEFT JOIN sbom_sources ON sbom_sources.id = sbom_occurrences.source_id
        WHERE
            sbom_occurrences.project_id = 1 AND
            (
                sbom_sources.source_type IN ( 0, 1 ) OR
                sbom_sources.source_type IS NULL
            ) AND
            sbom_occurrences.id NOT IN ( 1, 2 ) AND
            sbom_occurrences.id >= 3
    );

Related to #478376 (closed)

Edited by Brian Williams

Merge request reports

Loading