Add coredata batch loaders for tracker third parties
Surface the third-party links carried by tracker patterns (org-scoped
ThirdParty via third_party_id, or global CommonThirdParty via
common_tracker_pattern_id) requires three new batch loaders and two
filter dimensions, all kept inside their owning entity tables to honour
the no-cross-entity-JOIN rule.
* CommonTrackerPatterns gains LoadByIDs and the ID-only
LoadIDsByCommonThirdPartyID helper, which lets callers translate a
common third party into a set of common_tracker_pattern_id values
without ever JOINing against tracker_patterns.
* CommonThirdParties gains LoadByIDs.
* TrackerPatterns gains LoadDistinctThirdPartyIDsByCookieBannerID and
LoadDistinctCommonTrackerPatternIDsByCookieBannerID, used by the
upcoming CookieBanner.linkedThirdParties resolver to enumerate the
third parties referenced in a banner.
* TrackerPatternFilter gains thirdPartyID and commonTrackerPatternIDs
filter dimensions; the GraphQL layer will dispatch a single
thirdPartyId argument to the right one based on the GID entity-type
prefix.
Service-layer wrappers (cookiebanner.GetCommonTrackerPatternsByIDs,
cookiebanner.LoadCommonTrackerPatternIDsByCommonThirdPartyID,
cookiebanner.LoadDistinctThirdPartyIDsByCookieBannerID,
cookiebanner.LoadDistinctCommonTrackerPatternIDsByCookieBannerID, and
thirdparty.GetCommonThirdPartiesByIDs) expose the new loaders to the
console resolvers and dataloaders that follow.
Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
23
pkg/thirdparty/service.go
vendored
23
pkg/thirdparty/service.go
vendored
@@ -50,6 +50,29 @@ func (s *Service) GenerateLogoURL(
|
||||
return &url, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetCommonThirdPartiesByIDs(
|
||||
ctx context.Context,
|
||||
ids ...gid.GID,
|
||||
) (coredata.CommonThirdParties, error) {
|
||||
var parties coredata.CommonThirdParties
|
||||
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
if err := parties.LoadByIDs(ctx, conn, ids); err != nil {
|
||||
return fmt.Errorf("cannot load common third parties by ids: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return parties, nil
|
||||
}
|
||||
|
||||
func (s *Service) Search(ctx context.Context, name string) ([]*coredata.CommonThirdParty, error) {
|
||||
var parties coredata.CommonThirdParties
|
||||
|
||||
|
||||
Reference in New Issue
Block a user