MCPcopy Create free account
hub / github.com/bytebase/bytebase / CountActivePrincipals

Method CountActivePrincipals

backend/store/stats.go:29–40  ·  view source on GitHub ↗

CountActivePrincipals counts non-deleted principals cross-workspace. Used for display purposes (e.g. actuator info) — not for seat limit enforcement.

(ctx context.Context)

Source from the content-addressed store, hash-verified

27// CountActivePrincipals counts non-deleted principals cross-workspace. Used for display purposes
28// (e.g. actuator info) — not for seat limit enforcement.
29func (s *Store) CountActivePrincipals(ctx context.Context) (int, error) {
30 q := qb.Q().Space(`SELECT count(*) FROM principal WHERE deleted = FALSE`)
31 query, args, err := q.ToSQL()
32 if err != nil {
33 return 0, errors.Wrapf(err, "failed to build sql")
34 }
35 var count int
36 if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan(&count); err != nil {
37 return 0, err
38 }
39 return count, nil
40}

Callers 3

getServerInfoMethod · 0.80
countUsersInIamPolicyFunction · 0.80

Calls 5

GetDBMethod · 0.95
QFunction · 0.92
SpaceMethod · 0.80
ToSQLMethod · 0.80
ScanMethod · 0.80

Tested by

no test coverage detected