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

@@ -16,10 +16,8 @@ function PersonPageQueryLoader() {
const [queryRef, loadQuery] = useQueryLoader<PersonPageQuery>(personPageQuery); const [queryRef, loadQuery] = useQueryLoader<PersonPageQuery>(personPageQuery);
useEffect(() => { useEffect(() => {
if (!queryRef) { loadQuery({ personId });
loadQuery({ personId }); }, [personId, loadQuery]);
}
});
if (!queryRef) return <LinkCardSkeleton />; if (!queryRef) return <LinkCardSkeleton />;

View File

@@ -28,7 +28,7 @@ const fragment = graphql`
last: $last last: $last
before: $before before: $before
orderBy: $order orderBy: $order
) @connection(key: "PeopleListFragment_members") @required(action: THROW) { ) @connection(key: "PeopleListFragment_members", filter: ["orderBy"]) @required(action: THROW) {
__id __id
totalCount totalCount
edges @required(action: THROW) { edges @required(action: THROW) {

View File

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

View File

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

View File

@@ -6470,7 +6470,7 @@ func (r *profileConnectionResolver) TotalCount(ctx context.Context, obj *types.P
switch obj.Resolver.(type) { switch obj.Resolver.(type) {
case *stateOfApplicabilityResolver: 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 { if err != nil {
panic(fmt.Errorf("cannot count profiles: %w", err)) panic(fmt.Errorf("cannot count profiles: %w", err))
} }