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

Method CountActiveInstances

backend/store/stats.go:12–25  ·  view source on GitHub ↗

CountActiveInstances counts the number of instances.

(ctx context.Context, workspaceID string)

Source from the content-addressed store, hash-verified

10
11// CountActiveInstances counts the number of instances.
12func (s *Store) CountActiveInstances(ctx context.Context, workspaceID string) (int, error) {
13 q := qb.Q().Space("SELECT count(1) FROM instance WHERE instance.workspace = ?", workspaceID).And("instance.deleted = ?", false)
14
15 query, args, err := q.ToSQL()
16 if err != nil {
17 return 0, errors.Wrapf(err, "failed to build sql")
18 }
19
20 var count int
21 if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan(&count); err != nil {
22 return 0, err
23 }
24 return count, nil
25}
26
27// CountActivePrincipals counts non-deleted principals cross-workspace. Used for display purposes
28// (e.g. actuator info) — not for seat limit enforcement.

Callers 2

getServerInfoMethod · 0.80
instanceCountGuardMethod · 0.80

Calls 6

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

Tested by

no test coverage detected