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