Store cookie durations as max_age_seconds
Replace the free-form duration TEXT column with a nullable max_age_seconds INTEGER on both cookies and cookie_patterns tables. The SDK detector now sends raw seconds instead of humanized strings, eliminating locale-dependent comparisons in the pattern merge worker. Humanization happens at display time in the widget and console UI. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -224,9 +224,9 @@ func (r *cookieBannerVersionResolver) Categories(ctx context.Context, obj *types
|
||||
cookies := make([]*types.CookieBannerVersionCookie, len(cat.Cookies))
|
||||
for j, c := range cat.Cookies {
|
||||
cookies[j] = &types.CookieBannerVersionCookie{
|
||||
Name: c.Name,
|
||||
Duration: c.Duration,
|
||||
Description: c.Description,
|
||||
Name: c.Name,
|
||||
MaxAgeSeconds: c.MaxAgeSeconds,
|
||||
Description: c.Description,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,7 +754,7 @@ func (r *mutationResolver) CreateCookiePattern(ctx context.Context, input types.
|
||||
Pattern: input.Pattern,
|
||||
MatchType: input.MatchType,
|
||||
DisplayName: input.DisplayName,
|
||||
Duration: input.Duration,
|
||||
MaxAgeSeconds: input.MaxAgeSeconds,
|
||||
Description: input.Description,
|
||||
},
|
||||
)
|
||||
@@ -799,7 +799,7 @@ func (r *mutationResolver) UpdateCookiePattern(ctx context.Context, input types.
|
||||
cookiebanner.UpdateCookiePatternRequest{
|
||||
CookiePatternID: input.CookiePatternID,
|
||||
DisplayName: input.DisplayName,
|
||||
Duration: input.Duration,
|
||||
MaxAgeSeconds: gqlutils.UnwrapOmittable(input.MaxAgeSeconds),
|
||||
Description: input.Description,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -200,7 +200,7 @@ type CookiePattern implements Node {
|
||||
pattern: String!
|
||||
matchType: CookiePatternMatchType!
|
||||
displayName: String!
|
||||
duration: String!
|
||||
maxAgeSeconds: Int
|
||||
description: String!
|
||||
source: CookieSource!
|
||||
cookieCount: Int! @goField(forceResolver: true)
|
||||
@@ -243,7 +243,7 @@ type CookieBannerVersionCategory {
|
||||
|
||||
type CookieBannerVersionCookie {
|
||||
name: String!
|
||||
duration: String!
|
||||
maxAgeSeconds: Int
|
||||
description: String!
|
||||
}
|
||||
|
||||
@@ -434,14 +434,14 @@ input CreateCookiePatternInput {
|
||||
pattern: String!
|
||||
matchType: CookiePatternMatchType!
|
||||
displayName: String!
|
||||
duration: String!
|
||||
maxAgeSeconds: Int
|
||||
description: String!
|
||||
}
|
||||
|
||||
input UpdateCookiePatternInput {
|
||||
cookiePatternId: ID!
|
||||
displayName: String
|
||||
duration: String
|
||||
maxAgeSeconds: Int @goField(omittable: true)
|
||||
description: String
|
||||
}
|
||||
|
||||
|
||||
@@ -69,13 +69,13 @@ func NewCookiePattern(cp *coredata.CookiePattern) *CookiePattern {
|
||||
ID: cp.CookieBannerID,
|
||||
},
|
||||
},
|
||||
Pattern: cp.Pattern,
|
||||
MatchType: cp.MatchType,
|
||||
DisplayName: cp.DisplayName,
|
||||
Duration: cp.Duration,
|
||||
Description: cp.Description,
|
||||
Source: cp.Source,
|
||||
CreatedAt: cp.CreatedAt,
|
||||
UpdatedAt: cp.UpdatedAt,
|
||||
Pattern: cp.Pattern,
|
||||
MatchType: cp.MatchType,
|
||||
DisplayName: cp.DisplayName,
|
||||
MaxAgeSeconds: cp.MaxAgeSeconds,
|
||||
Description: cp.Description,
|
||||
Source: cp.Source,
|
||||
CreatedAt: cp.CreatedAt,
|
||||
UpdatedAt: cp.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user