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

Method GetExportArchive

backend/store/export_archive.go:24–63  ·  view source on GitHub ↗

GetExportArchive gets a export archive.

(ctx context.Context, workspaceID string, resourceID string)

Source from the content-addressed store, hash-verified

22
23// GetExportArchive gets a export archive.
24func (s *Store) GetExportArchive(ctx context.Context, workspaceID string, resourceID string) (*ExportArchiveMessage, error) {
25 q := qb.Q().Space(`
26 SELECT
27 resource_id,
28 workspace,
29 created_at,
30 bytes,
31 payload
32 FROM export_archive
33 WHERE resource_id = ?
34 `, resourceID).And("workspace = ?", workspaceID)
35
36 query, args, err := q.ToSQL()
37 if err != nil {
38 return nil, errors.Wrapf(err, "failed to build sql")
39 }
40
41 var exportArchive ExportArchiveMessage
42 var bytesVal, payload []byte
43 if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan(
44 &exportArchive.ResourceID,
45 &exportArchive.Workspace,
46 &exportArchive.CreatedAt,
47 &bytesVal,
48 &payload,
49 ); err != nil {
50 if err.Error() == "sql: no rows in result set" {
51 return nil, nil
52 }
53 return nil, err
54 }
55 exportArchivePayload := &storepb.ExportArchivePayload{}
56 if err := common.ProtojsonUnmarshaler.Unmarshal(payload, exportArchivePayload); err != nil {
57 return nil, err
58 }
59 exportArchive.Payload = exportArchivePayload
60 exportArchive.Bytes = bytesVal
61
62 return &exportArchive, nil
63}
64
65// CreateExportArchive creates a export archive.
66func (s *Store) CreateExportArchive(ctx context.Context, create *ExportArchiveMessage) (*ExportArchiveMessage, error) {

Callers 2

doExportFromIssueMethod · 0.80
convertToTaskRunFunction · 0.80

Calls 8

GetDBMethod · 0.95
QFunction · 0.92
AndMethod · 0.80
SpaceMethod · 0.80
ToSQLMethod · 0.80
ScanMethod · 0.80
UnmarshalMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected