MCPcopy
hub / github.com/wavetermdev/waveterm / DBFindTabForBlockId

Function DBFindTabForBlockId

pkg/wstore/wstore_dbops.go:364–391  ·  view source on GitHub ↗
(ctx context.Context, blockId string)

Source from the content-addressed store, hash-verified

362}
363
364func DBFindTabForBlockId(ctx context.Context, blockId string) (string, error) {
365 return WithTxRtn(ctx, func(tx *TxWrap) (string, error) {
366 iterNum := 1
367 for {
368 if iterNum > 5 {
369 return "", fmt.Errorf("too many iterations looking for tab in block parents")
370 }
371 query := `
372 SELECT json_extract(b.data, '$.parentoref') AS parentoref
373 FROM db_block b
374 WHERE b.oid = ?;`
375 parentORef := tx.GetString(query, blockId)
376 oref, err := waveobj.ParseORef(parentORef)
377 if err != nil {
378 return "", fmt.Errorf("bad block parent oref: %v", err)
379 }
380 if oref.OType == "tab" {
381 return oref.OID, nil
382 }
383 if oref.OType == "block" {
384 blockId = oref.OID
385 iterNum++
386 continue
387 }
388 return "", fmt.Errorf("bad parent oref type: %v", oref.OType)
389 }
390 })
391}
392
393func DBFindWorkspaceForTabId(ctx context.Context, tabId string) (string, error) {
394 return WithTxRtn(ctx, func(tx *TxWrap) (string, error) {

Callers 8

DeleteBlockCommandMethod · 0.92
BlockInfoCommandMethod · 0.92
resolveThisFunction · 0.92
resolveTabNumFunction · 0.92
resolveBlockFunction · 0.92
resolveViewFunction · 0.92
determineScopesFunction · 0.92
makeSwapTokenFunction · 0.92

Calls 3

ParseORefFunction · 0.92
GetStringMethod · 0.80
WithTxRtnFunction · 0.70

Tested by

no test coverage detected