Add CookieBannerFilter

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-10 12:44:57 +04:00
parent 84628683f2
commit 62c29810a5
2 changed files with 58 additions and 2 deletions

View File

@@ -170,6 +170,7 @@ func (b *CookieBanners) LoadByOrganizationID(
scope Scoper,
organizationID gid.GID,
cursor *page.Cursor[CookieBannerOrderField],
filter *CookieBannerFilter,
) error {
q := `
SELECT
@@ -189,12 +190,14 @@ WHERE
%s
AND organization_id = @organization_id
AND %s
AND %s
`
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
q = fmt.Sprintf(q, scope.SQLFragment(), filter.SQLFragment(), cursor.SQLFragment())
args := pgx.StrictNamedArgs{"organization_id": organizationID}
maps.Copy(args, scope.SQLArguments())
maps.Copy(args, filter.SQLArguments())
maps.Copy(args, cursor.SQLArguments())
rows, err := conn.Query(ctx, q, args)
@@ -217,6 +220,7 @@ func (b *CookieBanners) CountByOrganizationID(
conn pg.Querier,
scope Scoper,
organizationID gid.GID,
filter *CookieBannerFilter,
) (int, error) {
q := `
SELECT
@@ -226,12 +230,14 @@ FROM
WHERE
%s
AND organization_id = @organization_id
AND %s
`
q = fmt.Sprintf(q, scope.SQLFragment())
q = fmt.Sprintf(q, scope.SQLFragment(), filter.SQLFragment())
args := pgx.StrictNamedArgs{"organization_id": organizationID}
maps.Copy(args, scope.SQLArguments())
maps.Copy(args, filter.SQLArguments())
row := conn.QueryRow(ctx, q, args)