Clean up tracker mapping worker
Remove redundant resolveThirdParty fallback that re-attempted resolution with the same inputs, and rename LoadCommonThirdPartyIDByTrackerPatternID to LoadCommonThirdPartyIDByDomainMatch to reflect that it joins on initiator_domain. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -152,7 +152,7 @@ WHERE
|
|||||||
return count, nil
|
return count, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dts *DetectedTrackers) LoadCommonThirdPartyIDByTrackerPatternID(
|
func (dts *DetectedTrackers) LoadCommonThirdPartyIDByDomainMatch(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
conn pg.Querier,
|
conn pg.Querier,
|
||||||
trackerPatternID gid.GID,
|
trackerPatternID gid.GID,
|
||||||
|
|||||||
@@ -85,13 +85,6 @@ func (h *trackerMappingHandler) Process(ctx context.Context, tp coredata.Tracker
|
|||||||
commonPatternID, thirdPartyID = h.matchByDomain(ctx, tx, tp)
|
commonPatternID, thirdPartyID = h.matchByDomain(ctx, tx, tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if commonPatternID != nil && thirdPartyID == nil {
|
|
||||||
var cp coredata.CommonTrackerPattern
|
|
||||||
if err := cp.LoadByID(ctx, tx, *commonPatternID); err == nil {
|
|
||||||
thirdPartyID = h.resolveThirdParty(ctx, tx, tp, &cp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if commonPatternID != nil || thirdPartyID != nil {
|
if commonPatternID != nil || thirdPartyID != nil {
|
||||||
if err := tp.UpdateMapping(ctx, tx, commonPatternID, thirdPartyID); err != nil {
|
if err := tp.UpdateMapping(ctx, tx, commonPatternID, thirdPartyID); err != nil {
|
||||||
return fmt.Errorf("cannot update tracker pattern mapping: %w", err)
|
return fmt.Errorf("cannot update tracker pattern mapping: %w", err)
|
||||||
@@ -137,7 +130,7 @@ func (h *trackerMappingHandler) matchByDomain(
|
|||||||
tp coredata.TrackerPattern,
|
tp coredata.TrackerPattern,
|
||||||
) (*gid.GID, *gid.GID) {
|
) (*gid.GID, *gid.GID) {
|
||||||
var trackers coredata.DetectedTrackers
|
var trackers coredata.DetectedTrackers
|
||||||
commonThirdPartyID, err := trackers.LoadCommonThirdPartyIDByTrackerPatternID(ctx, tx, tp.ID)
|
commonThirdPartyID, err := trackers.LoadCommonThirdPartyIDByDomainMatch(ctx, tx, tp.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.logger.ErrorCtx(ctx, "cannot load common third party ID from domain", log.Error(err))
|
h.logger.ErrorCtx(ctx, "cannot load common third party ID from domain", log.Error(err))
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user