Filter uncategorised category at the SQL level

Instead of loading all categories and filtering out
UNCATEGORISED in Go, add LoadConsentCategoriesByCookieBannerID
which excludes it in the query. This avoids fetching data we
immediately discard and makes the intent explicit at each call
site.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-04 15:13:10 +04:00
parent 4f1ecabcec
commit d35b8777da
3 changed files with 65 additions and 16 deletions

View File

@@ -428,7 +428,7 @@ func (s *Service) ensureDraftVersionForBanner(
}
var categories coredata.CookieCategories
if err := categories.LoadAllByCookieBannerID(ctx, tx, scope, bannerID); err != nil {
if err := categories.LoadConsentCategoriesByCookieBannerID(ctx, tx, scope, bannerID); err != nil {
return nil, fmt.Errorf("cannot load cookie categories: %w", err)
}
@@ -1887,7 +1887,7 @@ func (s *Service) GetActiveBannerConfig(
}
var categories coredata.CookieCategories
if err := categories.LoadAllByCookieBannerID(ctx, conn, scope, banner.ID); err != nil {
if err := categories.LoadConsentCategoriesByCookieBannerID(ctx, conn, scope, banner.ID); err != nil {
return fmt.Errorf("cannot load cookie categories: %w", err)
}