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

Method GetActivatedInstanceCount

backend/store/instance.go:288–299  ·  view source on GitHub ↗

GetActivatedInstanceCount gets the number of activated instances.

(ctx context.Context, workspaceID string)

Source from the content-addressed store, hash-verified

286
287// GetActivatedInstanceCount gets the number of activated instances.
288func (s *Store) GetActivatedInstanceCount(ctx context.Context, workspaceID string) (int, error) {
289 q := qb.Q().Space("SELECT COUNT(1) FROM instance WHERE workspace = ?", workspaceID).And("(metadata ?? 'activation') AND (metadata->>'activation')::boolean = TRUE AND deleted = FALSE")
290 query, args, err := q.ToSQL()
291 if err != nil {
292 return 0, errors.Wrapf(err, "failed to build sql")
293 }
294 var count int
295 if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan(&count); err != nil {
296 return 0, err
297 }
298 return count, nil
299}
300
301func ValidateDataSources(dataSources []*storepb.DataSource) error {
302 dataSourceMap := map[string]bool{}

Callers 2

getServerInfoMethod · 0.45
checkActivationLimitMethod · 0.45

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