Wire new FK columns into existing coredata models
Add CommonTrackerPatternID and ThirdPartyID to TrackerPattern, CommonThirdPartyID to Vendor, InitiatorDomain to DetectedTracker. Register CommonThirdPartyDomain (93) and CommonTrackerPattern (94) entity types. Signed-off-by: Émile Ré <emile@getprobo.com> Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -36,6 +36,7 @@ type (
|
|||||||
Source *CookieSource `db:"source"`
|
Source *CookieSource `db:"source"`
|
||||||
ValueSize *int `db:"value_size"`
|
ValueSize *int `db:"value_size"`
|
||||||
InitiatorURL *string `db:"initiator_url"`
|
InitiatorURL *string `db:"initiator_url"`
|
||||||
|
InitiatorDomain *string `db:"initiator_domain"`
|
||||||
LastDetectedAt time.Time `db:"last_detected_at"`
|
LastDetectedAt time.Time `db:"last_detected_at"`
|
||||||
CreatedAt time.Time `db:"created_at"`
|
CreatedAt time.Time `db:"created_at"`
|
||||||
UpdatedAt time.Time `db:"updated_at"`
|
UpdatedAt time.Time `db:"updated_at"`
|
||||||
@@ -61,6 +62,7 @@ INSERT INTO detected_trackers (
|
|||||||
source,
|
source,
|
||||||
value_size,
|
value_size,
|
||||||
initiator_url,
|
initiator_url,
|
||||||
|
initiator_domain,
|
||||||
last_detected_at,
|
last_detected_at,
|
||||||
created_at,
|
created_at,
|
||||||
updated_at
|
updated_at
|
||||||
@@ -75,6 +77,7 @@ INSERT INTO detected_trackers (
|
|||||||
@source,
|
@source,
|
||||||
@value_size,
|
@value_size,
|
||||||
@initiator_url,
|
@initiator_url,
|
||||||
|
@initiator_domain,
|
||||||
@last_detected_at,
|
@last_detected_at,
|
||||||
@created_at,
|
@created_at,
|
||||||
@updated_at
|
@updated_at
|
||||||
@@ -87,6 +90,7 @@ ON CONFLICT (cookie_banner_id, tracker_type, identifier) DO UPDATE
|
|||||||
ELSE detected_trackers.source
|
ELSE detected_trackers.source
|
||||||
END,
|
END,
|
||||||
initiator_url = COALESCE(EXCLUDED.initiator_url, detected_trackers.initiator_url),
|
initiator_url = COALESCE(EXCLUDED.initiator_url, detected_trackers.initiator_url),
|
||||||
|
initiator_domain = COALESCE(EXCLUDED.initiator_domain, detected_trackers.initiator_domain),
|
||||||
updated_at = EXCLUDED.updated_at
|
updated_at = EXCLUDED.updated_at
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -102,6 +106,7 @@ ON CONFLICT (cookie_banner_id, tracker_type, identifier) DO UPDATE
|
|||||||
"source_script": CookieSourceScript,
|
"source_script": CookieSourceScript,
|
||||||
"value_size": dt.ValueSize,
|
"value_size": dt.ValueSize,
|
||||||
"initiator_url": dt.InitiatorURL,
|
"initiator_url": dt.InitiatorURL,
|
||||||
|
"initiator_domain": dt.InitiatorDomain,
|
||||||
"last_detected_at": dt.LastDetectedAt,
|
"last_detected_at": dt.LastDetectedAt,
|
||||||
"created_at": dt.CreatedAt,
|
"created_at": dt.CreatedAt,
|
||||||
"updated_at": dt.UpdatedAt,
|
"updated_at": dt.UpdatedAt,
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ const (
|
|||||||
DetectedTrackerEntityType uint16 = 90
|
DetectedTrackerEntityType uint16 = 90
|
||||||
TrackerResourceEntityType uint16 = 91
|
TrackerResourceEntityType uint16 = 91
|
||||||
CommonThirdPartyEntityType uint16 = 92
|
CommonThirdPartyEntityType uint16 = 92
|
||||||
|
CommonThirdPartyDomainEntityType uint16 = 93
|
||||||
|
CommonTrackerPatternEntityType uint16 = 94
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewEntityFromID(id gid.GID) (any, bool) {
|
func NewEntityFromID(id gid.GID) (any, bool) {
|
||||||
@@ -290,6 +292,10 @@ func NewEntityFromID(id gid.GID) (any, bool) {
|
|||||||
return &TrackerResource{ID: id}, true
|
return &TrackerResource{ID: id}, true
|
||||||
case CommonThirdPartyEntityType:
|
case CommonThirdPartyEntityType:
|
||||||
return &CommonThirdParty{ID: id}, true
|
return &CommonThirdParty{ID: id}, true
|
||||||
|
case CommonThirdPartyDomainEntityType:
|
||||||
|
return &CommonThirdPartyDomain{ID: id}, true
|
||||||
|
case CommonTrackerPatternEntityType:
|
||||||
|
return &CommonTrackerPattern{ID: id}, true
|
||||||
default:
|
default:
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ type (
|
|||||||
ID gid.GID `db:"id"`
|
ID gid.GID `db:"id"`
|
||||||
TenantID gid.TenantID `db:"tenant_id"`
|
TenantID gid.TenantID `db:"tenant_id"`
|
||||||
OrganizationID gid.GID `db:"organization_id"`
|
OrganizationID gid.GID `db:"organization_id"`
|
||||||
|
CommonThirdPartyID *gid.GID `db:"common_third_party_id"`
|
||||||
Name string `db:"name"`
|
Name string `db:"name"`
|
||||||
Description *string `db:"description"`
|
Description *string `db:"description"`
|
||||||
Category ThirdPartyCategory `db:"category"`
|
Category ThirdPartyCategory `db:"category"`
|
||||||
@@ -204,6 +205,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
@@ -270,6 +272,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
@@ -330,6 +333,7 @@ INSERT INTO
|
|||||||
tenant_id,
|
tenant_id,
|
||||||
id,
|
id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
@@ -357,6 +361,7 @@ VALUES (
|
|||||||
@tenant_id,
|
@tenant_id,
|
||||||
@third_party_id,
|
@third_party_id,
|
||||||
@organization_id,
|
@organization_id,
|
||||||
|
@common_third_party_id,
|
||||||
@name,
|
@name,
|
||||||
@description,
|
@description,
|
||||||
@category,
|
@category,
|
||||||
@@ -386,6 +391,7 @@ VALUES (
|
|||||||
"tenant_id": scope.GetTenantID(),
|
"tenant_id": scope.GetTenantID(),
|
||||||
"third_party_id": v.ID,
|
"third_party_id": v.ID,
|
||||||
"organization_id": v.OrganizationID,
|
"organization_id": v.OrganizationID,
|
||||||
|
"common_third_party_id": v.CommonThirdPartyID,
|
||||||
"name": v.Name,
|
"name": v.Name,
|
||||||
"description": v.Description,
|
"description": v.Description,
|
||||||
"category": v.Category,
|
"category": v.Category,
|
||||||
@@ -477,6 +483,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
@@ -539,6 +546,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
@@ -742,6 +750,7 @@ WITH vend AS (
|
|||||||
v.id,
|
v.id,
|
||||||
v.tenant_id,
|
v.tenant_id,
|
||||||
v.organization_id,
|
v.organization_id,
|
||||||
|
v.common_third_party_id,
|
||||||
v.name,
|
v.name,
|
||||||
v.description,
|
v.description,
|
||||||
v.category,
|
v.category,
|
||||||
@@ -775,6 +784,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
@@ -874,6 +884,7 @@ WITH vend AS (
|
|||||||
v.id,
|
v.id,
|
||||||
v.tenant_id,
|
v.tenant_id,
|
||||||
v.organization_id,
|
v.organization_id,
|
||||||
|
v.common_third_party_id,
|
||||||
v.name,
|
v.name,
|
||||||
v.description,
|
v.description,
|
||||||
v.category,
|
v.category,
|
||||||
@@ -907,6 +918,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
@@ -967,6 +979,7 @@ WITH vend AS (
|
|||||||
v.id,
|
v.id,
|
||||||
v.tenant_id,
|
v.tenant_id,
|
||||||
v.organization_id,
|
v.organization_id,
|
||||||
|
v.common_third_party_id,
|
||||||
v.name,
|
v.name,
|
||||||
v.description,
|
v.description,
|
||||||
v.category,
|
v.category,
|
||||||
@@ -1000,6 +1013,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
@@ -1061,6 +1075,7 @@ WITH vend AS (
|
|||||||
v.id,
|
v.id,
|
||||||
v.tenant_id,
|
v.tenant_id,
|
||||||
v.organization_id,
|
v.organization_id,
|
||||||
|
v.common_third_party_id,
|
||||||
v.name,
|
v.name,
|
||||||
v.description,
|
v.description,
|
||||||
v.category,
|
v.category,
|
||||||
@@ -1094,6 +1109,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
@@ -1218,6 +1234,7 @@ WITH vend AS (
|
|||||||
v.id,
|
v.id,
|
||||||
v.tenant_id,
|
v.tenant_id,
|
||||||
v.organization_id,
|
v.organization_id,
|
||||||
|
v.common_third_party_id,
|
||||||
v.name,
|
v.name,
|
||||||
v.description,
|
v.description,
|
||||||
v.category,
|
v.category,
|
||||||
@@ -1251,6 +1268,7 @@ SELECT
|
|||||||
id,
|
id,
|
||||||
tenant_id,
|
tenant_id,
|
||||||
organization_id,
|
organization_id,
|
||||||
|
common_third_party_id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
category,
|
category,
|
||||||
|
|||||||
@@ -31,21 +31,23 @@ import (
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
TrackerPattern struct {
|
TrackerPattern struct {
|
||||||
ID gid.GID `db:"id"`
|
ID gid.GID `db:"id"`
|
||||||
OrganizationID gid.GID `db:"organization_id"`
|
OrganizationID gid.GID `db:"organization_id"`
|
||||||
CookieBannerID gid.GID `db:"cookie_banner_id"`
|
CookieBannerID gid.GID `db:"cookie_banner_id"`
|
||||||
CookieCategoryID gid.GID `db:"cookie_category_id"`
|
CookieCategoryID gid.GID `db:"cookie_category_id"`
|
||||||
TrackerType TrackerType `db:"tracker_type"`
|
CommonTrackerPatternID *gid.GID `db:"common_tracker_pattern_id"`
|
||||||
Pattern string `db:"pattern"`
|
ThirdPartyID *gid.GID `db:"third_party_id"`
|
||||||
MatchType TrackerPatternMatchType `db:"match_type"`
|
TrackerType TrackerType `db:"tracker_type"`
|
||||||
DisplayName string `db:"display_name"`
|
Pattern string `db:"pattern"`
|
||||||
Description string `db:"description"`
|
MatchType TrackerPatternMatchType `db:"match_type"`
|
||||||
Excluded bool `db:"excluded"`
|
DisplayName string `db:"display_name"`
|
||||||
MaxAgeSeconds *int `db:"max_age_seconds"`
|
Description string `db:"description"`
|
||||||
Source *CookieSource `db:"source"`
|
Excluded bool `db:"excluded"`
|
||||||
LastMatchedAt *time.Time `db:"last_matched_at"`
|
MaxAgeSeconds *int `db:"max_age_seconds"`
|
||||||
CreatedAt time.Time `db:"created_at"`
|
Source *CookieSource `db:"source"`
|
||||||
UpdatedAt time.Time `db:"updated_at"`
|
LastMatchedAt *time.Time `db:"last_matched_at"`
|
||||||
|
CreatedAt time.Time `db:"created_at"`
|
||||||
|
UpdatedAt time.Time `db:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackerPatterns []*TrackerPattern
|
TrackerPatterns []*TrackerPattern
|
||||||
@@ -101,6 +103,8 @@ SELECT
|
|||||||
organization_id,
|
organization_id,
|
||||||
cookie_banner_id,
|
cookie_banner_id,
|
||||||
cookie_category_id,
|
cookie_category_id,
|
||||||
|
common_tracker_pattern_id,
|
||||||
|
third_party_id,
|
||||||
tracker_type,
|
tracker_type,
|
||||||
pattern,
|
pattern,
|
||||||
match_type,
|
match_type,
|
||||||
@@ -158,6 +162,8 @@ SELECT
|
|||||||
organization_id,
|
organization_id,
|
||||||
cookie_banner_id,
|
cookie_banner_id,
|
||||||
cookie_category_id,
|
cookie_category_id,
|
||||||
|
common_tracker_pattern_id,
|
||||||
|
third_party_id,
|
||||||
tracker_type,
|
tracker_type,
|
||||||
pattern,
|
pattern,
|
||||||
match_type,
|
match_type,
|
||||||
@@ -222,6 +228,8 @@ SELECT
|
|||||||
organization_id,
|
organization_id,
|
||||||
cookie_banner_id,
|
cookie_banner_id,
|
||||||
cookie_category_id,
|
cookie_category_id,
|
||||||
|
common_tracker_pattern_id,
|
||||||
|
third_party_id,
|
||||||
tracker_type,
|
tracker_type,
|
||||||
pattern,
|
pattern,
|
||||||
match_type,
|
match_type,
|
||||||
@@ -296,6 +304,8 @@ INSERT INTO tracker_patterns (
|
|||||||
organization_id,
|
organization_id,
|
||||||
cookie_banner_id,
|
cookie_banner_id,
|
||||||
cookie_category_id,
|
cookie_category_id,
|
||||||
|
common_tracker_pattern_id,
|
||||||
|
third_party_id,
|
||||||
tracker_type,
|
tracker_type,
|
||||||
pattern,
|
pattern,
|
||||||
match_type,
|
match_type,
|
||||||
@@ -313,6 +323,8 @@ INSERT INTO tracker_patterns (
|
|||||||
@organization_id,
|
@organization_id,
|
||||||
@cookie_banner_id,
|
@cookie_banner_id,
|
||||||
@cookie_category_id,
|
@cookie_category_id,
|
||||||
|
@common_tracker_pattern_id,
|
||||||
|
@third_party_id,
|
||||||
@tracker_type,
|
@tracker_type,
|
||||||
@pattern,
|
@pattern,
|
||||||
@match_type,
|
@match_type,
|
||||||
@@ -328,22 +340,24 @@ INSERT INTO tracker_patterns (
|
|||||||
`
|
`
|
||||||
|
|
||||||
args := pgx.StrictNamedArgs{
|
args := pgx.StrictNamedArgs{
|
||||||
"id": tp.ID,
|
"id": tp.ID,
|
||||||
"tenant_id": scope.GetTenantID(),
|
"tenant_id": scope.GetTenantID(),
|
||||||
"organization_id": tp.OrganizationID,
|
"organization_id": tp.OrganizationID,
|
||||||
"cookie_banner_id": tp.CookieBannerID,
|
"cookie_banner_id": tp.CookieBannerID,
|
||||||
"cookie_category_id": tp.CookieCategoryID,
|
"cookie_category_id": tp.CookieCategoryID,
|
||||||
"tracker_type": tp.TrackerType,
|
"common_tracker_pattern_id": tp.CommonTrackerPatternID,
|
||||||
"pattern": tp.Pattern,
|
"third_party_id": tp.ThirdPartyID,
|
||||||
"match_type": tp.MatchType,
|
"tracker_type": tp.TrackerType,
|
||||||
"display_name": tp.DisplayName,
|
"pattern": tp.Pattern,
|
||||||
"description": tp.Description,
|
"match_type": tp.MatchType,
|
||||||
"excluded": tp.Excluded,
|
"display_name": tp.DisplayName,
|
||||||
"max_age_seconds": tp.MaxAgeSeconds,
|
"description": tp.Description,
|
||||||
"source": tp.Source,
|
"excluded": tp.Excluded,
|
||||||
"last_matched_at": tp.LastMatchedAt,
|
"max_age_seconds": tp.MaxAgeSeconds,
|
||||||
"created_at": tp.CreatedAt,
|
"source": tp.Source,
|
||||||
"updated_at": tp.UpdatedAt,
|
"last_matched_at": tp.LastMatchedAt,
|
||||||
|
"created_at": tp.CreatedAt,
|
||||||
|
"updated_at": tp.UpdatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := tx.Exec(ctx, q, args)
|
_, err := tx.Exec(ctx, q, args)
|
||||||
@@ -371,6 +385,8 @@ INSERT INTO tracker_patterns (
|
|||||||
organization_id,
|
organization_id,
|
||||||
cookie_banner_id,
|
cookie_banner_id,
|
||||||
cookie_category_id,
|
cookie_category_id,
|
||||||
|
common_tracker_pattern_id,
|
||||||
|
third_party_id,
|
||||||
tracker_type,
|
tracker_type,
|
||||||
pattern,
|
pattern,
|
||||||
match_type,
|
match_type,
|
||||||
@@ -388,6 +404,8 @@ INSERT INTO tracker_patterns (
|
|||||||
@organization_id,
|
@organization_id,
|
||||||
@cookie_banner_id,
|
@cookie_banner_id,
|
||||||
@cookie_category_id,
|
@cookie_category_id,
|
||||||
|
@common_tracker_pattern_id,
|
||||||
|
@third_party_id,
|
||||||
@tracker_type,
|
@tracker_type,
|
||||||
@pattern,
|
@pattern,
|
||||||
@match_type,
|
@match_type,
|
||||||
@@ -404,22 +422,24 @@ ON CONFLICT (cookie_banner_id, tracker_type, pattern, COALESCE(max_age_seconds,
|
|||||||
`
|
`
|
||||||
|
|
||||||
args := pgx.StrictNamedArgs{
|
args := pgx.StrictNamedArgs{
|
||||||
"id": tp.ID,
|
"id": tp.ID,
|
||||||
"tenant_id": scope.GetTenantID(),
|
"tenant_id": scope.GetTenantID(),
|
||||||
"organization_id": tp.OrganizationID,
|
"organization_id": tp.OrganizationID,
|
||||||
"cookie_banner_id": tp.CookieBannerID,
|
"cookie_banner_id": tp.CookieBannerID,
|
||||||
"cookie_category_id": tp.CookieCategoryID,
|
"cookie_category_id": tp.CookieCategoryID,
|
||||||
"tracker_type": tp.TrackerType,
|
"common_tracker_pattern_id": tp.CommonTrackerPatternID,
|
||||||
"pattern": tp.Pattern,
|
"third_party_id": tp.ThirdPartyID,
|
||||||
"match_type": tp.MatchType,
|
"tracker_type": tp.TrackerType,
|
||||||
"display_name": tp.DisplayName,
|
"pattern": tp.Pattern,
|
||||||
"description": tp.Description,
|
"match_type": tp.MatchType,
|
||||||
"excluded": tp.Excluded,
|
"display_name": tp.DisplayName,
|
||||||
"max_age_seconds": tp.MaxAgeSeconds,
|
"description": tp.Description,
|
||||||
"source": tp.Source,
|
"excluded": tp.Excluded,
|
||||||
"last_matched_at": tp.LastMatchedAt,
|
"max_age_seconds": tp.MaxAgeSeconds,
|
||||||
"created_at": tp.CreatedAt,
|
"source": tp.Source,
|
||||||
"updated_at": tp.UpdatedAt,
|
"last_matched_at": tp.LastMatchedAt,
|
||||||
|
"created_at": tp.CreatedAt,
|
||||||
|
"updated_at": tp.UpdatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := tx.Exec(ctx, q, args)
|
result, err := tx.Exec(ctx, q, args)
|
||||||
@@ -525,6 +545,8 @@ SELECT
|
|||||||
organization_id,
|
organization_id,
|
||||||
cookie_banner_id,
|
cookie_banner_id,
|
||||||
cookie_category_id,
|
cookie_category_id,
|
||||||
|
common_tracker_pattern_id,
|
||||||
|
third_party_id,
|
||||||
tracker_type,
|
tracker_type,
|
||||||
pattern,
|
pattern,
|
||||||
match_type,
|
match_type,
|
||||||
@@ -621,6 +643,8 @@ SELECT
|
|||||||
organization_id,
|
organization_id,
|
||||||
cookie_banner_id,
|
cookie_banner_id,
|
||||||
cookie_category_id,
|
cookie_category_id,
|
||||||
|
common_tracker_pattern_id,
|
||||||
|
third_party_id,
|
||||||
tracker_type,
|
tracker_type,
|
||||||
pattern,
|
pattern,
|
||||||
match_type,
|
match_type,
|
||||||
@@ -730,6 +754,8 @@ SELECT
|
|||||||
organization_id,
|
organization_id,
|
||||||
cookie_banner_id,
|
cookie_banner_id,
|
||||||
cookie_category_id,
|
cookie_category_id,
|
||||||
|
common_tracker_pattern_id,
|
||||||
|
third_party_id,
|
||||||
tracker_type,
|
tracker_type,
|
||||||
pattern,
|
pattern,
|
||||||
match_type,
|
match_type,
|
||||||
|
|||||||
Reference in New Issue
Block a user