MCPcopy Index your code
hub / github.com/bytebase/bytebase / GetProjectByResourceID

Method GetProjectByResourceID

backend/store/runner_queries.go:23–55  ·  view source on GitHub ↗

GetProjectByResourceID gets a project by its globally unique resource ID without workspace filter. For use by runners that resolve workspace from the loaded entity.

(ctx context.Context, resourceID string)

Source from the content-addressed store, hash-verified

21// GetProjectByResourceID gets a project by its globally unique resource ID without workspace filter.
22// For use by runners that resolve workspace from the loaded entity.
23func (s *Store) GetProjectByResourceID(ctx context.Context, resourceID string) (*ProjectMessage, error) {
24 if v, ok := s.projectCache.Get(resourceID); ok && s.enableCache {
25 return v, nil
26 }
27
28 q := qb.Q().Space("SELECT resource_id, workspace, name, setting, deleted FROM project WHERE resource_id = ?", resourceID)
29 query, args, err := q.ToSQL()
30 if err != nil {
31 return nil, err
32 }
33
34 var project ProjectMessage
35 var payload []byte
36 if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan(
37 &project.ResourceID,
38 &project.Workspace,
39 &project.Title,
40 &payload,
41 &project.Deleted,
42 ); err != nil {
43 if err == sql.ErrNoRows {
44 return nil, nil
45 }
46 return nil, err
47 }
48 setting := &storepb.Project{}
49 if err := common.ProtojsonUnmarshaler.Unmarshal(payload, setting); err != nil {
50 return nil, err
51 }
52 project.Setting = setting
53 s.storeProjectCache(&project)
54 return &project, nil
55}
56
57// GetInstanceByResourceID gets an instance by its globally unique resource ID without workspace filter.
58// For use by runners that resolve workspace from the loaded entity.

Callers 11

processIssueMethod · 0.80
getApproversForRoleFunction · 0.80
failTaskRunsForHAMethod · 0.80
checkPlanCompletionMethod · 0.80
runTaskRunOnceMethod · 0.80
getMaxParallelForTaskMethod · 0.80
tryCreateRolloutMethod · 0.80
runPlanCheckRunMethod · 0.80

Calls 8

GetDBMethod · 0.95
storeProjectCacheMethod · 0.95
QFunction · 0.92
GetMethod · 0.80
SpaceMethod · 0.80
ToSQLMethod · 0.80
ScanMethod · 0.80
UnmarshalMethod · 0.80

Tested by

no test coverage detected