Fix profiles totalcount

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-02-12 11:43:42 +04:00
parent f033338cda
commit 00a4d9fff0
5 changed files with 11 additions and 9 deletions

View File

@@ -503,6 +503,7 @@ func (p *MembershipProfiles) CountByOrganizationID(
conn pg.Conn,
scope Scoper,
organizationID gid.GID,
filter *MembershipProfileFilter,
) (int, error) {
q := `
SELECT
@@ -511,13 +512,15 @@ FROM
iam_membership_profiles
WHERE
%s
AND %s
AND organization_id = @organization_id
`
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())
rows, err := conn.Query(ctx, q, args)
if err != nil {

View File

@@ -1072,6 +1072,7 @@ func (s *OrganizationService) ListProfiles(
func (s OrganizationService) CountProfiles(
ctx context.Context,
organizationID gid.GID,
filter *coredata.MembershipProfileFilter,
) (int, error) {
var (
scope = coredata.NewScopeFromObjectID(organizationID)
@@ -1082,7 +1083,7 @@ func (s OrganizationService) CountProfiles(
ctx,
func(conn pg.Conn) (err error) {
profiles := coredata.MembershipProfiles{}
count, err = profiles.CountByOrganizationID(ctx, conn, scope, organizationID)
count, err = profiles.CountByOrganizationID(ctx, conn, scope, organizationID, filter)
if err != nil {
return fmt.Errorf("cannot count profiles: %w", err)
}
@@ -2057,7 +2058,7 @@ func (s OrganizationService) CreateSCIMBridge(
ConnectorID: &connectorID,
Type: bridgeType,
State: coredata.SCIMBridgeStateActive, // Active immediately since connector already exists
ExcludedUserNames: []string{},
ExcludedUserNames: []string{},
CreatedAt: now,
UpdatedAt: now,
}

View File

@@ -6470,7 +6470,7 @@ func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.P
switch obj.Resolver.(type) {
case *stateOfApplicabilityResolver:
count, err := r.iam.OrganizationService.CountProfiles(ctx, obj.ParentID)
count, err := r.iam.OrganizationService.CountProfiles(ctx, obj.ParentID, obj.Filters)
if err != nil {
panic(fmt.Errorf("cannot count profiles: %w", err))
}