Use subquery for common third party filter

Replace the two-step ID-materializing pattern (fetch IDs in Go, pass
as ANY(@ids)) with an IN-subquery that keeps the filtering entirely
in the database and eliminates an extra round trip. Remove the now
unused LoadIDsByCommonThirdPartyID and its service wrapper. Update
the coredata rule to clarify that subqueries for filtering are OK.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-28 21:36:04 +02:00
parent 44aca07de3
commit ed93301a1f
5 changed files with 55 additions and 120 deletions

View File

@@ -217,17 +217,7 @@ func (r *cookieBannerResolver) TrackerPatterns(ctx context.Context, obj *types.C
case coredata.ThirdPartyEntityType:
coredataFilter = coredataFilter.WithThirdPartyID(filter.ThirdPartyID)
case coredata.CommonThirdPartyEntityType:
ids, err := r.cookieBanner.LoadCommonTrackerPatternIDsByCommonThirdPartyID(ctx, *filter.ThirdPartyID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot resolve common third party tracker patterns", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
if ids == nil {
ids = []gid.GID{}
}
coredataFilter = coredataFilter.WithCommonTrackerPatternIDs(ids)
coredataFilter = coredataFilter.WithCommonThirdPartyID(filter.ThirdPartyID)
default:
return nil, gqlutils.Invalidf(ctx, "thirdPartyId must reference a ThirdParty or CommonThirdParty")
}