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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user