Add total count to vendors connection

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-01-27 18:48:29 +04:00
parent b2b52318f5
commit 34a6ed1223
9 changed files with 198 additions and 17 deletions

View File

@@ -283,6 +283,7 @@ func (v *Vendors) CountByOrganizationID(
conn pg.Conn,
scope Scoper,
organizationID gid.GID,
filter *VendorFilter,
) (int, error) {
q := `
SELECT
@@ -292,12 +293,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)